Repository navigation
fix: serve pages in SPA mode when the route also has an API handler - #2354
Merged
Merged
Conversation
`matchAPIRoute` only counted a route as a page when it had a page component. SPA builds leave page components out of the server routes, so a route file exporting both a page and `GET` was treated as API-only. When its `GET` returned nothing, the handler stopped there and h3 answered 404. A catch-all like `[...404].tsx` with a `GET` turned every page into a 404. Use `route.page` alone. SSR routes with a page always have the component, so nothing changes there. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 45e83b5 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: |
brenelz
approved these changes
Oct 14, 2026
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.
Problem
With
ssr: false, a route file that exports both a page and an API handler breaks page requests. For example:Every URL this route matches returns 404 instead of the SPA shell. A catch-all matches every page without its own API route, so the whole app is a 404. The
experimentsfixture has this route.Cause
matchAPIRoutecounted a route as a page only when it had a page component:SPA builds leave page components out of the server routes (
dataOnlyin the server file router), soisPagewas always false there. When theGETreturnedundefined, the handler hitif (!match.isPage) return;and h3 answered 404.Fix
Use
route.pagealone. With SSR, a route with a page always has its component, so SSR doesn't change.Verification
basicfixture withexport const GET = () => undefinedadded to[...404].tsx, production builds://about/nopessr: false, beforessr: false, afterserver/routes.spec.ts. The SPA case fails without the fix.packages/start: 243 tests, typecheck, format check.apps/tests: unit plus Playwright (42, 42, 3).I found this while working on #2352. That PR also fixes the SPA server entry's missing
getServerFunctionMetaexport, which kept theexperimentsfixture from building withssr: falseat all.🤖 Generated with Claude Code