Skip to content

Commit 09296d0

Browse files
authored
chore: revert dev error when using use:enhance with +server (#13397)
This PR reverts #13197 since it cause an error for users that used SuperForm's helper that made +server responses compatible with use:enhance.
1 parent 180fa34 commit 09296d0

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
chore: don't error during development when using `use:enhance` with `+server` as some third party libraries make it possible to POST forms to it

documentation/docs/20-core-concepts/30-form-actions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ The easiest way to progressively enhance a form is to add the `use:enhance` acti
353353
<form method="POST" +++use:enhance+++>
354354
```
355355
356-
> [!NOTE] `use:enhance` can only be used with forms that have `method="POST"`. It will not work with `method="GET"`, which is the default for forms without a specified method. Attempting to use `use:enhance` on forms without `method="POST"` will result in an error.
356+
> [!NOTE] `use:enhance` can only be used with forms that have `method="POST"` and point to actions defined in a `+page.server.js` file. It will not work with `method="GET"`, which is the default for forms without a specified method. Attempting to use `use:enhance` on forms without `method="POST"` or posting to a `+server.js` endpoint will result in an error.
357357
358358
> [!NOTE] Yes, it's a little confusing that the `enhance` action and `<form action>` are both called 'action'. These docs are action-packed. Sorry.
359359

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

-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { DEV } from 'esm-env';
21
import { ENDPOINT_METHODS, PAGE_METHODS } from '../../constants.js';
32
import { negotiate } from '../../utils/http.js';
43
import { Redirect } from '../control.js';
@@ -11,10 +10,6 @@ import { method_not_allowed } from './utils.js';
1110
* @returns {Promise<Response>}
1211
*/
1312
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-
1813
const method = /** @type {import('types').HttpMethod} */ (event.request.method);
1914

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

0 commit comments

Comments
 (0)