fix: render pages over sibling endpoints without GET handlers - #16125
Merged
Conversation
🦋 Changeset detectedLatest commit: 70bf3c1 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 |
…6126) Follow-up to #16125. No behavioral change to the GET fix — this refactors the endpoint load + decide flow for readability and extends the "prefer page" behavior to HEAD requests. ## Refactor Restructures the endpoint loading and decision logic in `respond.js` into a single block with a positive `endpoint_can_handle` check, replacing: - the `await`-in-ternary pattern (hard to scan) - the duplicated `!route.page` check across load and use conditions - the double-negative condition for the HEAD-falls-back-to-GET case The "load, then maybe discard" intent is now explicit and colocated. ## HEAD fix Extends the "prefer page" behavior to HEAD requests. Previously, a HEAD request with `accept: */*` to a page+endpoint route where the endpoint had neither HEAD nor GET would get 405 from `render_endpoint`, even though the page could handle HEAD. Now the page is rendered instead. `render_endpoint` already falls back to GET for HEAD when GET exists — that case is preserved via the `endpoint_can_handle` check. Also extends the `Vary: Accept` header to HEAD responses for page+endpoint routes, since HEAD can now be routed to either. ## Tests - **HEAD request prefers page** when endpoint has no HEAD/GET/fallback - **POST to post-only endpoint** with sibling page still hits the endpoint - **Fallback handler used** instead of page when endpoint has no GET but has `fallback` (new `fallback-with-page` test route) - **Content negotiation**: `accept: application/json` hits endpoint, `accept: text/html` hits page (using existing `routing/content-negotiation` route)
Rich-Harris
reviewed
Jun 23, 2026
Rich-Harris
approved these changes
Jun 23, 2026
Rich-Harris
left a comment
Member
There was a problem hiding this comment.
small suggestion but otherwise LGTM
Co-authored-by: Rich Harris <richard.a.harris@gmail.com>
Member
|
/autofix |
Rich-Harris
pushed a commit
that referenced
this pull request
Jun 26, 2026
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to version-3, this PR will be updated.⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ `version-3` is currently in **pre mode** so this branch has prereleases rather than normal releases. If you want to exit prereleases, run `changeset pre exit` on `version-3`.⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ # Releases ## @sveltejs/adapter-netlify@7.0.0-next.1 ### Major Changes - breaking: require `vite@^8.0.12`, the first Vite 8 release bundling stable `rolldown` 1.0.0 ([#16134](#16134)) ### Patch Changes - Updated dependencies [[`a9629f1`](a9629f1), [`53d37f9`](53d37f9), [`dba6239`](dba6239), [`ab12cb6`](ab12cb6), [`f0eab52`](f0eab52), [`cd884c1`](cd884c1), [`9ed38a8`](9ed38a8), [`53aa049`](53aa049), [`984e57a`](984e57a), [`51785be`](51785be), [`4f6bcbb`](4f6bcbb), [`78e7137`](78e7137)]: - @sveltejs/kit@3.0.0-next.5 ## @sveltejs/adapter-node@6.0.0-next.1 ### Major Changes - breaking: require `vite@^8.0.12`, the first Vite 8 release bundling stable `rolldown` 1.0.0 ([#16134](#16134)) ### Patch Changes - Updated dependencies [[`a9629f1`](a9629f1), [`53d37f9`](53d37f9), [`dba6239`](dba6239), [`ab12cb6`](ab12cb6), [`f0eab52`](f0eab52), [`cd884c1`](cd884c1), [`9ed38a8`](9ed38a8), [`53aa049`](53aa049), [`984e57a`](984e57a), [`51785be`](51785be), [`4f6bcbb`](4f6bcbb), [`78e7137`](78e7137)]: - @sveltejs/kit@3.0.0-next.5 ## @sveltejs/adapter-vercel@7.0.0-next.1 ### Major Changes - breaking: require `vite@^8.0.12`, the first Vite 8 release bundling stable `rolldown` 1.0.0 ([#16134](#16134)) ### Patch Changes - Updated dependencies [[`a9629f1`](a9629f1), [`53d37f9`](53d37f9), [`dba6239`](dba6239), [`ab12cb6`](ab12cb6), [`f0eab52`](f0eab52), [`cd884c1`](cd884c1), [`9ed38a8`](9ed38a8), [`53aa049`](53aa049), [`984e57a`](984e57a), [`51785be`](51785be), [`4f6bcbb`](4f6bcbb), [`78e7137`](78e7137)]: - @sveltejs/kit@3.0.0-next.5 ## @sveltejs/enhanced-img@1.0.0-next.1 ### Major Changes - breaking: require `vite@^8.0.12`, the first Vite 8 release bundling stable `rolldown` 1.0.0 ([#16134](#16134)) ## @sveltejs/kit@3.0.0-next.5 ### Major Changes - breaking: remove `base`, `assets`, and `resolveRoute` from `$app/paths` ([#15507](#15507)) - breaking: require Svelte config options to be passed through the Vite plugin ([#16007](#16007)) - breaking: `goto` now rejects when called with a URL that does not resolve to a route within the app, matching the existing behaviour for external URLs ([#16164](#16164)) - breaking: add 'error' result type to `preloadData` ([#12579](#12579)) - breaking: require `vite@^8.0.12`, the first Vite 8 release bundling stable `rolldown` 1.0.0 ([#16134](#16134)) ### Minor Changes - feat: expose `submitted` property of remote forms ([#14811](#14811)) ### Patch Changes - fix: clear issues and touched states on form reset ([#16163](#16163)) - fix: return 404 for form actions and remote functions whose name is an `Object.prototype` member ([#16072](#16072)) - feat: send periodic `keep-alive` SSE comments from `query.live` to prevent idle-timeout errors ([#16063](#16063)) - fix: render pages over sibling endpoints without GET or HEAD handlers ([#16125](#16125)) - fix: sort directory entries when building the route manifest so node indices are deterministic across runtimes (e.g. Bun and Node) ([#16074](#16074)) - fix: include hoisted packages in Vite's `server.fs.allow` list ([#15998](#15998)) ## @sveltejs/package@3.0.0-next.1 ### Patch Changes - fix: declare typescript as an optional peer dependency so svelte-package works under strict node-linkers ([#16073](#16073)) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This was referenced Jul 14, 2026
Rich-Harris
pushed a commit
that referenced
this pull request
Jul 20, 2026
…ndler (#16349) closes #10863 `is_endpoint_request()` routes POST to a sibling `+server.js` whenever the request isn't a native form submission (no `x-sveltekit-action` header) and the `Accept` header doesn't clearly prefer `text/html`. If that endpoint has no `POST` handler, `render_endpoint` returns a bare 405 instead of ever trying the page's `actions`, even when the page has a matching action that could serve the request. This adds one check after the endpoint is resolved: if it's a POST and the endpoint has neither `POST` nor `fallback`, treat it as unusable and fall through to the page instead. This mirrors the `endpoint_can_handle` pattern already used for GET/HEAD in `version-3` (#16125), extended here to POST for `main`. New fixture at `endpoint-output/actions-with-endpoint`: a page with `actions` next to a `+server.js` that only exports `GET`. --- ### Please don't delete this checklist! Before submitting the PR, please make sure you do the following: - [x] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs - [x] This message body should clearly illustrate what problems it solves. - [x] Ideally, include a test that fails without this PR but passes with it. ### Tests - [x] Run the tests with `pnpm test` and lint the project with `pnpm lint` and `pnpm check` ### Changesets - [x] If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running `pnpm changeset` and following the prompts. Changesets that add features should be `minor` and those that fix bugs should be `patch`. Please prefix changeset messages with `feat:`, `fix:`, or `chore:`. ### Edits - [x] Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.
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 #11794