fix(dev-server): delegate preview to Nitro when building with Nitro v3 - #2294
Conversation
When Nitro controls the production server, its `configurePreviewServer` hook handles requests. SolidStart's hook runs first and throws because `dist/server/entry-server.*` does not exist after a Nitro build, which stops Vite's hook loop before reaching the `nitro:preview` hook. Detect this by checking for the Nitro build output marker (`.output/nitro.json`). If present, skip the SolidStart preview middleware so the Nitro hook can handle preview instead. Fixes solidjs#2291
🦋 Changeset detectedLatest commit: 76ad73d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for solid-start-landing-page ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
commit: |
|
Since this PR is marked as Fixes #2291, I would like to clarify the current status. I opened #2291 to work with the maintainers on determining where and how the issue should be addressed. At the time this PR was opened, that discussion was still in progress and no implementation direction had been agreed upon. A maintainer has since indicated that the problem may be related to nitrojs/nitro#4509. I have therefore closed #2291 for now to wait for the Nitro-side work and verify it against the original reproduction. |
Problem
When using the official Nitro v3 Vite plugin with
preset: "node-server",vite previewfails with:SolidStart's
configurePreviewServerhook runs before thenitro:previewhook. Since Nitro stores the server entry at.output/server/index.mjsinstead ofdist/server/entry-server.*,resolvePreviewServerEntrythrows, stopping Vite's hook loop before Nitro's hook can handle the request.Fix
Check for the Nitro build output marker (
.output/nitro.json). If present and the file declares aserverEntry, SolidStart skips its own preview middleware and lets thenitro:previewhook handle requests.Verification
vite build+vite previewwith Nitro v3 → succeeds (preview delegated to Nitro)vite build+vite previewwithout Nitro → unchanged behavior (SolidStart middleware still used)dist/server/entry-server.*checked as beforeFixes #2291