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
fix(vite): route extensionless URLs matching a nitro route to nitro under asset sec-fetch-dest
`<img src="/api/image">` sends `sec-fetch-dest: image`, which the dev
middleware was treating as an asset load and forwarding to vite — even
when the URL had no extension and matched an explicit nitro route.
now an explicit nitro route always reaches nitro, except when the URL
also has an asset-like extension (preserving #4234, where a splat must
not swallow `<script src=".../entry-client.ts">`).
closes#4241
// Sec-Fetch-* is only sent on "potentially trustworthy" origins, so on plain-HTTP non-loopback (e.g. http://10.0.0.x) it's absent and a splat Nitro route may swallow browser asset loads (#4234). When the header is missing, treat known asset extensions without `text/html` in Accept as asset loads and let Vite handle them.
// No file extension (not /src/index.ts) unless it is an explicit Nitro route
266
-
(!ext||isNitroRoute)&&
259
+
// An explicit Nitro route reaches Nitro even when the request is tagged as an asset (e.g. `<img src="/api/image">` with `sec-fetch-dest: image`, #4241), UNLESS the URL also has an asset-like extension — in that case Vite stays the definitive handler so a splat doesn't swallow `<script src=".../entry-client.ts">` (#4234).
// #4241: `<img src="/api/image">` sends `sec-fetch-dest: image`. The URL has no extension but matches an explicit Nitro splat route, so it must reach Nitro instead of being treated as a Vite asset load.
52
+
test("routes extensionless URLs matching a Nitro route to Nitro even when sec-fetch-dest tags the request as an asset",async()=>{
// Browsers omit Sec-Fetch-* on plain-HTTP non-loopback origins (e.g. http://10.0.0.x:3000). Without that signal, a splat Nitro route would swallow `<script src=".../entry-client.ts">` requests. Accept + asset extension is used as a fallback to keep asset loads routed to Vite.
51
62
test("does not misroute asset loads to splat Nitro routes when sec-fetch-dest is absent",async()=>{
0 commit comments