diff --git a/.changeset/hot-brooms-sleep.md b/.changeset/hot-brooms-sleep.md new file mode 100644 index 000000000000..53f85d0ee5dd --- /dev/null +++ b/.changeset/hot-brooms-sleep.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Fix TypeError when a GET form uses a relative `formaction` attribute with ClientRouter enabled diff --git a/packages/astro/components/ClientRouter.astro b/packages/astro/components/ClientRouter.astro index 57685589c4d6..511765ef30de 100644 --- a/packages/astro/components/ClientRouter.astro +++ b/packages/astro/components/ClientRouter.astro @@ -136,7 +136,7 @@ const { fallback = 'animate' } = Astro.props; const options: Options = { sourceElement: submitter ?? form }; if (method === 'get') { const params = new URLSearchParams(formData as any); - const url = new URL(action); + const url = new URL(action, location.href); url.search = params.toString(); action = url.toString(); } else {