Fix guides · Next.js, Vercel ·

Fix Next.js 16 proxy files not allowing runtime config

Next.js 16 proxy files do not allow a runtime configuration

Next.js 16 deprecates middleware.ts in favor of proxy.ts. Unlike middleware.ts, proxy files run only on the Node.js runtime — a proxy file cannot set a runtime, and Edge-only middleware must stay as middleware.ts.

Free · 3 a day · no signup

Common causes – and how to tell which one you have

1. Runtime config in proxy file

How to tell: Build warns that middleware.ts is deprecated and suggests proxy.ts, but the file contains a 'runtime' configuration object. Proxy files in Next.js 16 run only on the Node.js runtime, so runtime configuration is not allowed.

Fix: If the middleware depends on Edge (runtime: 'edge' or Edge-only APIs), keep the file as middleware.ts. Otherwise, rename middleware.ts to proxy.ts, remove any runtime config, and export a proxy function without runtime settings.

2. Incorrect file location

How to tell: The file is not at the project root or in src/ next to app/ or pages/; proxy files in Next.js 16 must be at project root or src/ directory.

Fix: Move the file to project root or src/ next to app/ or pages/ and rename to proxy.ts if needed.

How to fix it

  1. Confirm you are on Next.js 16 or later; proxy files run only on the Node.js runtime and cannot set runtime: 'edge'.
  2. Locate the middleware file (e.g., middleware.ts) at the project root or in src/ next to app/.
  3. Check whether the middleware uses Edge-only APIs or exports a config object with runtime: 'edge'.
  4. If it does, keep the file as middleware.ts — Edge still works there — and do not rename it to proxy.ts.
  5. If it does not, rename middleware.ts to proxy.ts, rename the exported function to proxy, and keep all auth/redirect/header logic so protections are preserved.
  6. Run next build and confirm the deprecation warning is gone, then test auth/redirects.

Using Lovable, Bolt or v0?

Tell tool: \"Next.js middleware.ts is deprecated in favor of proxy.ts. Rename middleware.ts to proxy.ts, rename exported middleware to proxy, keep all auth/redirect/header logic, run next build, confirm deprecation warning gone. Do not delete middleware without an equivalent proxy.ts.\"

The “fix” to avoid

Do not delete middleware.ts without replacing it — that removes auth/redirect/rewrite protection. Do not move middleware logic into an API route; API routes cannot run before every request the way middleware/proxy does.

Copy-paste fix prompt for your AI coding tool

Paste this into Cursor, Claude Code, Lovable or Bolt:

My Next.js app shows 'The \"middleware\" file convention is deprecated. Please use \"proxy\" instead.' Next.js 16 removed support for runtime config in proxy files. First check whether the file uses Edge-only APIs or has a 'runtime' config, then keep it as middleware.ts if needed or rename to proxy.ts without runtime settings.
Your error looks a bit different? Paste your exact error and get a diagnosis tailored to your code — free.

Questions people ask

Does middleware.ts still work in Next.js 16?

Yes, middleware.ts still works but is deprecated with a warning. Renaming to proxy.ts is the forward-compatible fix.

Where does proxy.ts go?

At the project root or in src/ next to app/, not inside /api or /middleware.

Can I keep middleware.ts if it uses Edge-only APIs?

Yes. Edge-only middleware must stay as middleware.ts; proxy files run only on the Node.js runtime and cannot support Edge-only APIs.

Related errors

Get fixes like this every week