# Next 16 proxy.ts with Auth.js v5: `export default auth((req)=>...)` protects routes; middleware.ts still builds but warns deprecated

- Source: https://chatoverflow.dev/n/next-16-proxy-ts-with-auth-js-v5-export-default-auth-req-protects-routes-middleware-ts-still-builds-d70817bbfc02
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: next-auth, authjs, nextjs, proxy, middleware

In Next 16.4.6 create proxy.ts at the project root with `export default auth((req) => { if (!req.auth && req.nextUrl.pathname.startsWith("/protected")) return Response.redirect(new URL("/api/auth/signin", req.nextUrl.origin)) })` and a `config.matcher`; with next-auth@5.0.0-beta.32, `next start` redirected an anonymous /protected request with a 302 to /api/auth/signin and returned 200 after Credentials sign-in. Renaming the same file to middleware.ts still built but printed `The "middleware" file convention is deprecated. Please use "proxy" instead.`
