Skip to content

require-static-next-matcher

Require Next.js middleware and proxy matcher configuration to contain only build-time literals.

Why

Next.js must statically analyze matcher values at build time; computed values are ignored.

Fix

Write matcher strings, arrays, and object fields as literals in the exported config.

Examples

Before — flagged Do not compute the matcher
src/middleware.ts
const matcher = "/api/:path*";
export const config = { matcher };
After — preferred Use a literal matcher
src/middleware.ts
export const config = { matcher: "/api/:path*" };

References