Skip to content

Commit 00e1a76

Browse files
authored
chore: error during development when using use:enhance with +server (#13197)
Related to the hard-to-debug error talked about in #10855
1 parent 9fcd1e7 commit 00e1a76

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

.changeset/nine-parrots-smoke.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
chore: error during development when using `use:enhance` with `+server`

packages/kit/src/runtime/server/endpoint.js

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { DEV } from 'esm-env';
12
import { ENDPOINT_METHODS, PAGE_METHODS } from '../../constants.js';
23
import { negotiate } from '../../utils/http.js';
34
import { Redirect } from '../control.js';
@@ -10,6 +11,10 @@ import { method_not_allowed } from './utils.js';
1011
* @returns {Promise<Response>}
1112
*/
1213
export async function render_endpoint(event, mod, state) {
14+
if (DEV && event.request.headers.get('x-sveltekit-action') === 'true') {
15+
throw new Error('use:enhance should only be used with SvelteKit form actions');
16+
}
17+
1318
const method = /** @type {import('types').HttpMethod} */ (event.request.method);
1419

1520
let handler = mod[method] || mod.fallback;

0 commit comments

Comments
 (0)