Next.js · build warning

The "middleware" file convention is deprecated

what it looks like
⚠ The "middleware" file convention is deprecated. Please use "proxy" instead.

  To migrate automatically, run:
  npx @next/codemod@canary middleware-to-proxy .

What it means

Next.js 16 renamed middleware.ts to proxy.ts. Agents keep creating middleware.ts because most examples predate the rename. Proxy runs on the Node.js runtime, and the runtime option isn't allowed in proxy files.

Common causes

  • An agent added auth or redirects in middleware.ts
  • Code copied from Next.js 13–15 or Auth.js v4 examples

How to fix it

  1. Run npx @next/codemod@canary middleware-to-proxy . or rename the file and the exported function to proxy
  2. Remove any export const runtime = "edge" from it
  3. Keep matchers in export const config as before
src/proxy.ts
import { NextResponse, type NextRequest } from "next/server";

export function proxy(request: NextRequest) {
  return NextResponse.next();
}

export const config = { matcher: ["/dashboard/:path*"] };

works with Next.js 16.4.3 · React 19.3last verified

prevent it · nextjs-app-router.mdc (free Cursor Rules Pack): On Next.js 16 the agent writes proxy.ts exporting proxy instead of middleware.ts.

Prompt for Cursor or Claude Code

This is Next.js 16: middleware.ts is deprecated in favor of proxy.ts. Migrate it (rename the file and the exported function to proxy, keep the matcher config, remove any runtime export) and check nothing else imports the old file.

Not quite your error? Paste yours into the free VibeBoot Doctor or browse the Next.js error fixer.

next: skip the next one

Skip the debugging. The VibeBoot SaaS Starter ships with this already handled: it follows the Next.js 16 conventions (src/proxy.ts, Server Components by default, request-time data in <Suspense>) and its AGENTS.md and .cursor/rules keep your agent on them. Plus auth, Stripe and a database on Next.js 16.4.3. $49, one-time.

14-day money-back guarantee · lifetime updates

$ fixed it? get the next one first

New fixes for what AI agents break, by email.

When we add a fix or a Cursor rule for a new Next.js, Auth.js, Prisma or Stripe break, it goes out in the VibeBoot newsletter. Free, occasional, unsubscribe in one click.

Subscribe free