You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Server side fetch during dev and production runs different #4500
I can confirm the reported behavior. Reproduced on both v2 (nitropack 2.13.4) and v3 (main branch, commit 16ff280, built locally), running on real Node.js v22.20.0.
curl localhost:3000/ (handler does internal fetch)
curl localhost:3000/test.json
dev
❌ 404
✅ 200
build + node .output/server/index.mjs
✅ 200
✅ 200
Results are identical on v2 and v3.
Repro setup
Both versions: server/public/test.json with { "hello": "world" }.
If I'm reading the source correctly, this is consistent with how the internal fetch is wired: requests starting with / are dispatched directly to the h3 app, without going through HTTP (src/runtime/internal/app.ts).
The static assets handler is mounted in dev too, but it looks assets up in a manifest generated by scanning output.publicDir (src/build/virtual/public-assets.ts), and that directory is only populated by copyPublicAssets() during nitro build.
In dev the manifest stays empty, so the handler falls through and the router returns 404.
Public assets in dev are actually served by the dev server process (src/dev/app.ts) — outside the worker's h3 app, so a direct app-call fetch never reaches that layer.
So the issue can be narrowed down to: internal (server-side) fetch of a public asset while the dev server is running. Production (node-server preset) works, and fetching /test.json directly over HTTP works in both modes.
If this is confirmed as a bug (and not intended dev behavior), I'd be happy to work on a fix — any pointers on the preferred direction would be appreciated.
Activity
meta-syntax commentedon Aug 12, 2026
I can confirm the reported behavior. Reproduced on both v2 (nitropack 2.13.4) and v3 (main branch, commit 16ff280, built locally), running on real Node.js v22.20.0.
curl localhost:3000/(handler does internal fetch)curl localhost:3000/test.jsondevbuild+node .output/server/index.mjsResults are identical on v2 and v3.
Repro setup
Both versions:
server/public/test.jsonwith{ "hello": "world" }.v2 (nitropack 2.13.4)
v3 (main)
If I'm reading the source correctly, this is consistent with how the internal fetch is wired: requests starting with
/are dispatched directly to the h3 app, without going through HTTP (src/runtime/internal/app.ts).The static assets handler is mounted in dev too, but it looks assets up in a manifest generated by scanning
output.publicDir(src/build/virtual/public-assets.ts), and that directory is only populated bycopyPublicAssets()duringnitro build.In dev the manifest stays empty, so the handler falls through and the router returns 404.
Public assets in dev are actually served by the dev server process (
src/dev/app.ts) — outside the worker's h3 app, so a direct app-call fetch never reaches that layer.So the issue can be narrowed down to: internal (server-side) fetch of a public asset while the dev server is running. Production (node-server preset) works, and fetching
/test.jsondirectly over HTTP works in both modes.If this is confirmed as a bug (and not intended dev behavior), I'd be happy to work on a fix — any pointers on the preferred direction would be appreciated.
$fetchcannot fetch files inpublic/directory isomorphically nuxt/nuxt#13857 as a duplicate of this issue