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 6 of 6

Where Proxy sits in the pipeline, and the Server Actions edge case

The installed proxy.md reference lists Next.js's own documented execution order:

  1. headers from next.config.js
  2. redirects from next.config.js
  3. Proxy (rewrites, redirects, etc.)
  4. beforeFiles rewrites from next.config.js
  5. Filesystem routes (public/, pages/, app/, ...)
  6. afterFiles rewrites
  7. Dynamic routes
  8. fallback rewrites

Proxy runs third — after next.config.js's own static headers/redirects, but before a single file in app/ is even looked at. The docs add one sharp, non-obvious warning worth carrying into Part 15 before writing any auth proxy: "Server Functions are not separate routes in this chain. They are handled as POST requests to the route where they are used, so a Proxy matcher that excludes a path will also skip Server Function calls on that path... A matcher change or a refactor that moves a Server Function to a different route can silently remove Proxy coverage." Part 12's swiggy-menu Server Actions live entirely outside this part's /status matcher, so they're unaffected here — but the moment a proxy is asked to do anything security-relevant (Part 15's whole subject), this is the exact trap: a matcher that looks like it covers "the app" can quietly stop covering a Server Action that moved routes, with no error anywhere to say so.

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

Search the guide