Skip to content

Commit

Permalink
chore: error during development when using use:enhance with `+serve…
Browse files Browse the repository at this point in the history
…r` (#13197)

Related to the hard-to-debug error talked about in #10855
  • Loading branch information
eltigerchino authored Jan 15, 2025
1 parent 9fcd1e7 commit 00e1a76
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/nine-parrots-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

chore: error during development when using `use:enhance` with `+server`
5 changes: 5 additions & 0 deletions packages/kit/src/runtime/server/endpoint.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DEV } from 'esm-env';
import { ENDPOINT_METHODS, PAGE_METHODS } from '../../constants.js';
import { negotiate } from '../../utils/http.js';
import { Redirect } from '../control.js';
Expand All @@ -10,6 +11,10 @@ import { method_not_allowed } from './utils.js';
* @returns {Promise<Response>}
*/
export async function render_endpoint(event, mod, state) {
if (DEV && event.request.headers.get('x-sveltekit-action') === 'true') {
throw new Error('use:enhance should only be used with SvelteKit form actions');
}

const method = /** @type {import('types').HttpMethod} */ (event.request.method);

let handler = mod[method] || mod.fallback;
Expand Down

0 comments on commit 00e1a76

Please sign in to comment.