From 492648ea362eab0b70a5b67a7686d992c4121417 Mon Sep 17 00:00:00 2001 From: Chew Tee Ming Date: Fri, 31 Jan 2025 10:25:35 +0800 Subject: [PATCH 1/3] revert dev error --- packages/kit/src/runtime/server/endpoint.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/kit/src/runtime/server/endpoint.js b/packages/kit/src/runtime/server/endpoint.js index 3d1dcd48fc26..55bcd87807b9 100644 --- a/packages/kit/src/runtime/server/endpoint.js +++ b/packages/kit/src/runtime/server/endpoint.js @@ -1,4 +1,3 @@ -import { DEV } from 'esm-env'; import { ENDPOINT_METHODS, PAGE_METHODS } from '../../constants.js'; import { negotiate } from '../../utils/http.js'; import { Redirect } from '../control.js'; @@ -11,10 +10,6 @@ import { method_not_allowed } from './utils.js'; * @returns {Promise} */ 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; From e0cc5cc5fcc308945718fe5fe7479aea4a4b31a4 Mon Sep 17 00:00:00 2001 From: Chew Tee Ming Date: Fri, 31 Jan 2025 10:27:59 +0800 Subject: [PATCH 2/3] changeset --- .changeset/lovely-starfishes-impress.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/lovely-starfishes-impress.md diff --git a/.changeset/lovely-starfishes-impress.md b/.changeset/lovely-starfishes-impress.md new file mode 100644 index 000000000000..404c73c9cd46 --- /dev/null +++ b/.changeset/lovely-starfishes-impress.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +chore: revert the changes from #13197 to error during development when using `use:enhance` with `+server` From 09580d5004512e76fd7400110798c634ac62a0ff Mon Sep 17 00:00:00 2001 From: Simon H <5968653+dummdidumm@users.noreply.github.com> Date: Fri, 31 Jan 2025 10:35:10 +0100 Subject: [PATCH 3/3] docs, changeset tweak --- .changeset/lovely-starfishes-impress.md | 2 +- documentation/docs/20-core-concepts/30-form-actions.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/lovely-starfishes-impress.md b/.changeset/lovely-starfishes-impress.md index 404c73c9cd46..b8e51c2ce4f5 100644 --- a/.changeset/lovely-starfishes-impress.md +++ b/.changeset/lovely-starfishes-impress.md @@ -2,4 +2,4 @@ '@sveltejs/kit': patch --- -chore: revert the changes from #13197 to error during development when using `use:enhance` with `+server` +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 diff --git a/documentation/docs/20-core-concepts/30-form-actions.md b/documentation/docs/20-core-concepts/30-form-actions.md index fdad1d71485a..86c3b02233a5 100644 --- a/documentation/docs/20-core-concepts/30-form-actions.md +++ b/documentation/docs/20-core-concepts/30-form-actions.md @@ -353,7 +353,7 @@ The easiest way to progressively enhance a form is to add the `use:enhance` acti
``` -> [!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. +> [!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. > [!NOTE] Yes, it's a little confusing that the `enhance` action and `` are both called 'action'. These docs are action-packed. Sorry.