Vercel preset: missing paths always run the fallback function, even when every page is prerendered and a 404.html exists
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 51/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- node.js, typescript
Research direction
Start by tracing the Vercel preset code that writes .vercel/output/config.json and the handling of vercel.config.routes; the issue does not name those source files. Compare its generated catch-all route with the cloudflare_module preset's not-found handling. Define and test how static 404 routing should interact with filesystem handling, prerendered pages, and server routes; done means missing paths serve the prerendered /404.html without invoking the fallback while server routes still work.
Written by the indexing model from the issue text.
Description
Describe the feature
On a hybrid Nuxt build (nuxt build --preset vercel) where every page route is prerendered, any path with no file still goes to the server function. The last route Nitro writes to .vercel/output/config.json is
{ "src": "/(.*)", "dest": "/__fallback" }
so /no-such-page/, /wp-login.php, /.env and every other bot probe runs /__fallback to render a 404. That is the case even when /404.html is prerendered into .vercel/output/static/: the catch-all comes first, so the static page is never used.
Nitro already does the static thing for asset misses: after { "handle": "filesystem" } it writes "status": 404 routes for ^/_nuxt/(.*)$ and friends, so those never reach a function. We'd like a supported way to get the same for everything else.
Why it matters: sites like this need nuxt build only for a handful of server routes (here, one CMS preview endpoint) and are otherwise fully static. Each missing path is a function invocation, which on Vercel's paid plans is billed work that anyone can trigger. On Next.js the same kind of site serves its 404 from a static file.
Reproduction: https://github.com/KevinBlakeLopez/nuxt-hybrid-404-repro. Nuxt 4.7.0, nitropack 2.14.0, Node 24.14.1. No deployment needed:
pnpm install
WITH_404=1 pnpm build:vercel && pnpm check
404.html in static output: true
Routes after "filesystem" that return a static 404:
^/_nuxt/builds/meta/(.*)$
^/_nuxt/builds/(.*)$
^/_nuxt/(.*)$
Routes after "filesystem" that go to a function:
^(?<__isr_route>/__nuxt_error/?)$ -> /__fallback
/api/preview -> /api/preview
/__nuxt_error -> /__nuxt_error
/__nuxt_island(?:/(?:.*))? -> /__nuxt_island/[...]
/(.*) -> /__fallback
Last route (catches every path with no file): {"src":"/(.*)","dest":"/__fallback"}
On a real Vercel deployment of a similar app (Nuxt 4.x, nitropack 2.x, November 2026), unknown URLs returned 404 with x-vercel-cache: MISS and a function region in the request id on every request, while prerendered pages were cache HITs with no function.
What we found doesn't help:
vercel.config.routescan't do it. In the repro, a{ src: '/(.*)', status: 404, dest: '/404.html' }route added there lands first inconfig.json, before{ "handle": "filesystem" }, so it would 404 every page. The generated/(.*)->/__fallbackroute is still written last.nuxt generategives a static 404 but drops the server routes.- A local build with Nitro 3.0.261103-rc (
vercelpreset) writes the same pair of catch-alls (/[...slug]and/__server), so this isn't fixed by upgrading. (Read in the build output, not deployed.)
Possible shapes (we're happy with whichever fits Nitro best):
- An opt-in option, for example
vercel.staticNotFound: true, that ends the routes with{ "src": "/(.*)", "status": 404, "dest": "/404.html" }instead of the fallback function, and prerenders/404.htmlif it isn't already. - Do that automatically when every page route has
prerender: trueand a404.htmlwas prerendered. - Let
vercel.configadd routes after the generated catch-all, or replace it.
For comparison, the cloudflare_module preset already gets close with existing options: cloudflare.deployConfig: true plus cloudflare.wrangler.assets.not_found_handling: '404-page' and a prerendered /404.html (the repro's WITH_404=1 pnpm build:cloudflare writes both). Per Cloudflare's docs that serves the static page to navigations without running the Worker; we haven't deployed it.
Additional information
- Would you be willing to help implement this feature?
- Dominant language
- TypeScript
- Stars
- 11.5k
- Forks
- 968
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 64
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nitrojs/nitro
-
pending triage
Difficulty 1/5 Under an hour Newbie friendliness 92/100
Maintainers usually reply within 2 days
-
Difficulty 1/5 Under an hour Newbie friendliness 95/100
Maintainers usually reply within 2 days
-
cloudflare: `nitro deploy` fails when a parent directory has a Wrangler configPossibly taken @draarivpatel-ui claimed this 13 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Maintainers usually reply within 2 days
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 2 days
-
pending triage
Difficulty 5/5 Over a week Newbie friendliness 30/100
nitrojs/nitro#5205 · 1 reaction ·
Maintainers usually reply within 2 days
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ranxianglei/billion-context#8319 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
JimLiu/open-artifact#126 ·
-
bug repro-ready
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
mksglu/context-mode#1454 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
laststance/design-world#98 ·
Maintainers usually reply within 1 day
-
Add: KCM True crimeOpenapproved check:passed streams:add
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day