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
Using Nitro via nitro/vite inside a Vite dev server
Public repro currently uses TanStack Start to demonstrate the behavior, but the suspected problem appears to be in Nitro's dev middleware / Vite handoff
Open the LAN/IP URL printed by Vite, for example http://192.168.100.27:3000/feedback/dev-test
On both pages:
click the next-missing button
answer both required questions
type in the optional textarea
Compare behavior
Describe the bug
In dev mode, internal Vite asset/module requests can be handled incorrectly on LAN/IP access when Sec-Fetch-Dest is missing
In the repro:
localhost works
the same valid page on the LAN/IP URL SSR-renders but client behavior stays stale
an internal Vite request returns HTML instead of the expected JavaScript module response
This does not look like app-specific state logic
The same page and route are valid, and the failure only appears when internal dev asset handling differs between localhost and LAN/IP access
Expected:
internal Vite module requests should still be delegated correctly even when Sec-Fetch-Dest is missing
localhost and LAN/IP access should behave the same in dev mode
Actual:
on the failing LAN/IP path, an internal request such as vite/dist/client/env.mjs can return 404 text/html
hydration-dependent UI then stops behaving correctly because the expected module response was not served
Additional context
The repro includes two modes:
pnpm dev:broken
pnpm dev:patched
The patched mode applies a dev-only middleware before Nitro handling that sets:
req.headers["sec-fetch-dest"] = "script"
when the header is missing for obvious internal module requests such as:
/@vite/client
/@react-refresh
/@vite/env
/@id/*
/src/*.(css|js|ts|tsx|mjs|cjs|mts|cts)
/node_modules/* with those extensions
On my machine:
broken mode:
localhost passes
LAN/IP fails
vite/dist/client/env.mjs returns 404 text/html on the LAN path
patched mode:
localhost passes
LAN/IP passes
the same internal request returns a JavaScript module response
This makes it look like the bug is in the dev middleware routing / handoff decision when Fetch Metadata headers are missing, rather than in application code
Environment
3.0.1-20260402-182549-a5a3389cv24.14.18.0.70.10.8.1Reproduction
Relevant setup:
nitro/viteinside a Vite dev serverhttps://github.com/Neonsy/tanstack-start-lan-dev-repro
pnpm installpnpm dev:brokenhttp://localhost:3000/feedback/dev-testhttp://192.168.100.27:3000/feedback/dev-testDescribe the bug
In dev mode, internal Vite asset/module requests can be handled incorrectly on LAN/IP access when
Sec-Fetch-Destis missingIn the repro:
localhostworksThis does not look like app-specific state logic
The same page and route are valid, and the failure only appears when internal dev asset handling differs between
localhostand LAN/IP accessExpected:
Sec-Fetch-Destis missinglocalhostand LAN/IP access should behave the same in dev modeActual:
vite/dist/client/env.mjscan return404 text/htmlAdditional context
The repro includes two modes:
pnpm dev:brokenpnpm dev:patchedThe patched mode applies a dev-only middleware before Nitro handling that sets:
req.headers["sec-fetch-dest"] = "script"when the header is missing for obvious internal module requests such as:
/@vite/client/@react-refresh/@vite/env/@id/*/src/*.(css|js|ts|tsx|mjs|cjs|mts|cts)/node_modules/*with those extensionsOn my machine:
localhostpassesvite/dist/client/env.mjsreturns404 text/htmlon the LAN pathlocalhostpassesThis makes it look like the bug is in the dev middleware routing / handoff decision when Fetch Metadata headers are missing, rather than in application code
Related downstream report:
Sec-Fetch-Destalso lets Nitro intercept route module requests containing$id, producing a redirect / 404 instead of a JS module responseNote
This issue derived from my issue, placed on the tanstack repo
Logs