Repository navigation
fix(devframe): let a devframe at base / fall through to the host app - #478
Merged
antfu merged 1 commit intoNov 2, 2026
Merged
Conversation
A devframe mounted at `/` through `nodeMiddleware` answered every
unmatched path with h3's 404, so `devframeViteBridge(def, { base: '/' })`
hid the Vite app's own pages. Unmatched requests at base `/` now call
the host's `next()`. Bases like `/__<id>/` keep owning their namespace.
The tutorial's Vite config also sets `root` to `app/`, so
`vite --config app/vite.config.ts` serves `app/index.html`.
Fixes devframes#456
|
@zerone0x is attempting to deploy a commit to the NuxtLabs Team on Vercel. A member of the Team first needs to authorize it. |
|
👁️🗨️ Review this pull request with grouped, summarized diffs at: raw result💭 analyzed by {
"headSha": "463f7d765d2bb5d1d2429faebc73f0c4ce7c9238",
"result": {
"overallSummary": "Fixes a bug where mounting a devframe at base `/` (as in the tutorial) caused every request, including the host app's own pages, to be answered by the devframe's h3 404 instead of falling through to the host (e.g. Vite). The core fix adds an end-of-chain fall-through middleware for base `/`, with new tests covering both the devframe adapter and the Vite bridge, plus a tutorial docs fix for a missing Vite `root`.",
"groups": [
{
"key": "fallthrough-fix",
"label": "Base `/` fall-through fix",
"summary": "When a devframe is mounted at base `/`, it previously answered every unmatched request with its own 404 instead of letting the host app (e.g. Vite) handle it. Adds a fall-through middleware, mounted last in the chain, that forwards unmatched requests to the host's `next()` when base is `/`, while leaving the `/__<id>/` base behavior unchanged.",
"category": "core",
"filePaths": [
"packages/devframe/src/node/instance-shell.ts",
"packages/devframe/src/adapters/initiate.ts"
],
"critical": true,
"fileNotes": [
{
"path": "packages/devframe/src/node/instance-shell.ts",
"text": "`hostFallthrough` tracks the pending `next` per in-flight request via a WeakMap keyed on the raw node request, consumed once by the end-of-chain middleware registered in `mountHostFallthrough`."
}
]
},
{
"key": "tests",
"label": "Fall-through tests",
"summary": "New tests exercising the base `/` fall-through: unmatched paths reach the host's `next()`/Vite's own middlewares while devframe routes like `__connection.json` keep answering, and `handler` still 404s when there's no `next` to fall back to.",
"category": "tests",
"filePaths": [
"packages/devframe/src/adapters/__tests__/initiate.test.ts",
"packages/vite/test/single.test.ts"
]
},
{
"key": "docs",
"label": "Tutorial root fix",
"summary": "Adds a `root` option to the tutorial's `vite.config.ts` snippet so running `vite` from a different cwd still finds `index.html` and matches the configured `outDir`.",
"category": "docs",
"filePaths": [
"docs/content/1.guide/1.tutorial-server-data-inspector.md"
]
}
],
"schemaVersion": 1,
"source": "llm",
"generatedAt": "2026-11-01T16:30:27.139Z",
"model": "vercel-ai-gateway/anthropic/claude-sonnet-5",
"locale": "en"
}
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #456
Problem
Step 3 of the tutorial mounts
devframeViteBridge(def, { base: '/', auth: false }). Opening the Vite URL returns:I could reproduce this on
mainwith the tutorial files copied as written. There were two causes:nodeMiddlewareruns before Vite's own middlewares. At base/, every request is inside the base, so h3 answered/,/main.tsxand every other path with its 404.next()was never called, so Vite never served the page. Setting a correctrootalone does not fix this.root.npx vite --config app/vite.config.tsuses the current folder as the Vite root. That folder has noindex.html; the file is inapp/. The config'sbuild.outDir: '../dist/client'and Step 4'sclientAssetspath both expect the root to beapp/.Fix
createInstanceShell(used bynodeMiddleware): when the base is/, a request that no devframe route answers now goes to the host'snext()instead of h3's 404. A devframe at/shares the origin root with its host app, so it cannot own every path. This is done by one middleware at the end of the chain. It uses h3'sfromNodeHandlerand waits until the host stack has sent its response. Bases like/__<id>/do not change: inside its own base the devframe still owns the namespace. Existing tests check this, for example the reservedembedded.js404 and the unmounted__sse404. The webhandlerdoes not change either.root: fileURLToPath(new URL('.', import.meta.url))toapp/vite.config.ts, the same wayexamples/files-inspectordoes it.nodeMiddlewareJSDoc to describe the base/case.Test plan
packages/devframe/src/adapters/__tests__/initiate.test.ts: at base/,nodeMiddlewaresends/,/main.tsxand/nested/page?x=1to the host'snext().__connection.jsonstill answers, andhandlerstill returns 404 for a miss. This test fails without the fix.packages/vite/test/single.test.ts:devframeViteBridgeat base/leaves pages to the middleware registered after it.npx vite --config app/vite.config.tsnow serves/and/main.tsxwith 200.__connection.jsonanswers, and over/__ws,data-inspector:get-metaanddata-inspector:query('users.0.name')return the expected values.npx vite build --config app/vite.config.tswritesdist/client/.pnpm lint,pnpm knip,pnpm typecheck,pnpm build,vitest run(160 files, 1829 passed) andpnpm docs:buildall pass.