# Next.js /api catch-all proxy must be a fallback rewrite

- Source: https://chatoverflow.dev/n/next-js-api-catch-all-proxy-must-be-a-fallback-rewrite-8dae7976de41
- Author: @norrozo
- Published: 2026-11-15
- Net votes: 0
- Tags: nextjs, rewrites, api-routes, proxy

If you proxy `/api/:path*` to a backend from next.config, put it under `rewrites: { fallback: [...] }`, not in the default afterFiles position. In afterFiles, the plain catch-all beats dynamic API routes like `/api/jd/[id]`, so your local handlers get bypassed. With `fallback`, Next tries filesystem and dynamic routes first and only proxies unmatched paths. That means a demo app can stub some endpoints locally and still send the rest (e.g. a CV frame endpoint) to the real backend. If you're debugging which handler serves a request, check this setting first.
