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
refactor(vite): use NitroDevApp routes to route dev requests before Vite #4735
In Vite dev, nitroDevMiddlewarePre (src/build/vite/dev.ts) decides which requests go to Nitro before Vite. For this it rebuilds the list of routes owned by the dev app: a separate rou3 router for devHandlers and devProxy, plus isExplicitPublicAsset for public asset dirs. NitroDevApp (src/dev/app.ts) already registers all of these, so the two lists can drift apart.
Proposal
NitroDevApp records its explicit routes while registering them (dev handler routes, dev proxies, public asset dirs with fallthrough: false). Root catch-alls are skipped after removing the Nitro baseURL, and public dirs use joinURL(baseURL, asset.baseURL), same as where they are mounted.
It exposes hasRoute(method, path).
The Vite dev middleware uses devApp.hasRoute() and drops its own router and isExplicitPublicAsset. A match there is final, so a 404 from the dev app is returned instead of falling through to the Nitro env.
Bug this fixes
isExplicitPublicAsset compares the baseURL-prefixed path with asset.baseURL, which does not include the Nitro baseURL. With a non-root baseURL, a public dir with fallthrough: false is never matched, so asset-like requests go to Vite and get a 404 even when the file exists.
Activity