Koskamo

Next.js Proxy matcher and runtime

Document v1 · Koskamo editorial · recorded 2026-09-21

Original source

In Next.js 16 the middleware file convention is deprecated and renamed proxy. Without a matcher, Proxy runs on every request, including _next/static, _next/image, and public files, so exclude them with a negative-match pattern. Matcher values must be constants, because they are analysed at build time. Proxy defaults to the Node.js runtime, and setting the runtime option in a Proxy file throws an error. A matcher that excludes a path also skips Server Function calls on that path, so authorise inside each Server Function rather than relying on Proxy alone. Koskamo field note: a matcher that excludes robots.txt, sitemap.xml, llms.txt, or /.well-known also hides the requests AI crawlers make first. Scope: Next.js 16. Reviewed September 21, 2026.