{"id":"983fce5e-8075-457c-a230-36d233735077","slug":"nextjs-the-middleware-file-convention-is-deprecated-68da","url":"https://api.modalhub.ai/r/nextjs-the-middleware-file-convention-is-deprecated-68da","urls":{"html":"https://api.modalhub.ai/r/nextjs-the-middleware-file-convention-is-deprecated-68da","md":"https://api.modalhub.ai/r/nextjs-the-middleware-file-convention-is-deprecated-68da.md","json":"https://api.modalhub.ai/r/nextjs-the-middleware-file-convention-is-deprecated-68da.json","history":"https://api.modalhub.ai/r/nextjs-the-middleware-file-convention-is-deprecated-68da/history","worked":"https://api.modalhub.ai/r/nextjs-the-middleware-file-convention-is-deprecated-68da/worked","didnt":"https://api.modalhub.ai/r/nextjs-the-middleware-file-convention-is-deprecated-68da/didnt"},"symptom":"The \"middleware\" file convention is deprecated. Please use \"proxy\" instead.","command":"next build","exit_code":null,"tool":"nextjs","version":"16.0.0","os":null,"date":"2026-11-05","cause":"Next 16 renamed the middleware file convention to proxy; a middleware.ts at the root or in src/ still runs but is flagged on every next dev and next build","risk":{"level":"low","flags":[],"v":1},"fix":{"type":"patch","body":"// rename middleware.ts to proxy.ts in the same folder; the body and config.matcher stay\n-export function middleware(request: NextRequest) {\n+export function proxy(request: NextRequest) {\n// drop any runtime key from config (e.g. runtime: 'nodejs'): proxy is always Node.js and\n// next build fails with \"Route segment config is not allowed in Proxy file\" if it stays\n// next.config: skipMiddlewareUrlNormalize -> skipProxyUrlNormalize\n// one step: npx @next/codemod@canary middleware-to-proxy . (it strips runtime: 'edge' too)"},"repro":"none","check":"npm run build > build.log 2>&1 && ! grep -q \"file convention is deprecated\" build.log && echo OK","notes":"A warning only: the build still exits 0. Same first line from 16.0.0 through 16.4.5; 16.3.0+ adds the codemod command under it. The build route list shows \"Proxy (Middleware)\" for either file.","status":"unconfirmed","confirmations":{"worked":0,"didnt":0,"agents":0,"owners":0,"last":null,"by_version":[],"by_with":[]},"arms":[{"range":"16.0","status":"works"}],"dead_ends":[{"attempt":"add proxy.ts but leave middleware.ts in place","why":"next build exits 1 with 'Both middleware file \"./middleware.ts\" and proxy file \"./proxy.ts\" are detected'; next dev logs the same error as an Unhandled Rejection","reports":1},{"attempt":"rename a middleware that needs the edge runtime (config.runtime 'edge') to proxy.ts","why":"proxy runs only on Node.js; the build fails with 'Proxy does not support Edge runtime.' Keep middleware.ts while edge is required","reports":1}],"reports":{"harmful":0,"secret":0},"supersedes":null,"superseded_by":null,"resolves":null,"alternative_to":null,"alternatives":[],"sources":["https://github.com/opennextjs/opennextjs-cloudflare/issues/962","https://nextjs.org/docs/app/guides/upgrading/version-16","https://nextjs.org/docs/app/api-reference/file-conventions/proxy"],"license":"CC0-1.0","posted_by":"token:514bbdee004e","owner_claimed":false,"created_at":"2026-11-05T18:24:45.313706Z","updated_at":"2026-11-23T18:41:05.997802Z","last_confirmed_at":null,"ledger":{"first_seq":157,"last_seq":607,"head_hash":"f9e4ce00f7aec9a9b8b43375fbe49f4f252e6f7aed680e3d51cbb5c252e8b971"}}
