feat: support the QUERY HTTP method in +server.js - #16782
Conversation
RFC 10008 defines QUERY, a safe method that carries a request body. A named `QUERY` export in `+server.js` was rejected by the server-export allowlist, so the only way to answer a QUERY request was `fallback`. Add QUERY to `valid_server_exports`, to `ENDPOINT_METHODS` so it is routed to the endpoint regardless of the `accept` header and reported in the `allow` header of a 405, and to the `HttpMethod` type.
|
Install the latest version of pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/4f0da8392545fbaadf8da36bde0043fbcfea4e4eOpen in Note This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed. |
🦋 Changeset detectedLatest commit: 4f0da83 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 |
|
I don’t know if this is something we want to add yet (or at all). You can always use https://svelte.dev/docs/kit/routing#server-Fallback-method-handler to support this |
|
@teemingc No worries man. Do you want me to fix a flaky test you had? |
Yes, we’d appreciate that. Which test are you talking about? |
QUERY responses depend on the request body, so they can never be served statically. Extend both prerender guards to match the mutative methods, otherwise the handler builds silently and 404s in production.
BODY_DEPENDENT_METHODS is MUTATIVE_METHODS plus QUERY, which is excluded from prerendering for a different reason: the response depends on the request body. Extending ENDPOINT_METHODS without the hand-copied guard lists is how the QUERY gap happened in the first place.
|
I think the one that he fixed |
Add the new HTTP method
Adding the new QUERY method.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits