middleware → proxy
Next.js 16 renames Middleware to Proxy. The feature is unchanged — it still intercepts requests at the network boundary before a request completes — but the file and the exported function are renamed to make that boundary explicit.
Rename middleware.ts to proxy.ts and rename the exported function to
proxy:
// proxy.ts
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
export function proxy(request: NextRequest) {
return NextResponse.redirect(new URL('/home', request.url));
}
export const config = {
matcher: '/about/:path*',
};
The config.matcher option is unchanged: it still filters which paths run
through Proxy, so it only runs where you need it. Configuration flags that
carried the old name change too — for example skipMiddlewareUrlNormalize
becomes skipProxyUrlNormalize.
Two runtime details matter. Proxy runs on the Node.js runtime, and this
cannot be configured. If you still need the Edge runtime, middleware.ts
remains available, but it is deprecated and will be removed in a future
version, so plan the migration.
proxy.ts is for rewrites, redirects, and header changes — not slow data
fetching or full authorization.
You are about to answer a short quiz on the proxy.ts rename.