Course map
Stage 1: App Router Foundations
Stage 2: The Rendering Model
Stage 3: Data, Caching and Mutations
Stage 4: Full-Stack Next.js
Stage 5: Production and Specialization

Part 14 / Topic 5 of 6

matcher — why an unscoped proxy is dangerous, reproduced for real

The installed proxy.md reference's own warning: "Without a matcher, Proxy runs on every request, including static files (_next/static), image optimizations (_next/image), and assets in the public/ folder... auth logic or redirects can unintentionally block CSS, JS, or images from loading." This harness's real proxy.ts is scoped:

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

To see what the warning describes concretely, a scratch version with no config export at all (examples/04-unscoped-proxy-demo.ts) was built and run against this same harness, setting one harmless header instead of anything that could actually break a page:

$ curl -s -D - -o /dev/null http://localhost:PORT/mandi | grep -i "x-proxy-ran"
x-proxy-ran: 1
$ curl -s -D - -o /dev/null http://localhost:PORT/favicon.ico | grep -i "x-proxy-ran"
x-proxy-ran: 1

/mandi has nothing to do with this proxy's own logic, and /favicon.ico isn't a page at all — a static file — and the unscoped proxy still ran for both. This is exactly the scenario the docs' warning describes: a matcher-less proxy that happened to redirect unauthenticated users, say, would redirect a request for the site's own CSS file too, since nothing told it not to. The real, scoped proxy.ts this harness keeps was rebuilt immediately after this check, and the scratch variant was deleted.

Done here? The practice set for Part 14 — including the solutions — is on the part page.

Search the guide