Vercel preset: missing paths always run the fallback function, even when every page is prerendered and a 404.html exists
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 51/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- node.js, typescript
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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?
- Lingua principale
- TypeScript
- Stelle
- 11.5k
- Fork
- 968
- Merge medio
- 4g 9h
- PR unite (30g)
- 64
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di nitrojs/nitro
-
pending triage
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
I maintainer di solito rispondono entro 2 giorni
-
cloudflare: `nitro deploy` fails when a parent directory has a Wrangler configForse già presa @draarivpatel-ui l’ha presa 13 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
I maintainer di solito rispondono entro 2 giorni
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 2 giorni
-
pending triage
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
nitrojs/nitro#5205 · 1 reazione ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di nitrojs/nitro
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
amosblomqvist/learnharness#1141 ·
I maintainer di solito rispondono entro 4 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
ranxianglei/billion-context#8319 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
tencent-connect/dsh-qqbot#148 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
JimLiu/open-artifact#126 ·
-
redis.expireTime() returns relative TTL seconds on live host instead of Unix timestamp secondsAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100