From bedd3b1226f9bb031ea2cfc0fb56a8686a2f6b67 Mon Sep 17 00:00:00 2001 From: Geoff Rich <4992896+geoffrich@users.noreply.github.com> Date: Sat, 13 Jul 2024 16:04:07 -0700 Subject: [PATCH] fix: work around SWA issue with empty form bodies --- files/entry.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/files/entry.js b/files/entry.js index 857ce44..1b418fc 100644 --- a/files/entry.js +++ b/files/entry.js @@ -66,6 +66,12 @@ function toRequest(context) { // this header contains the URL the user requested const originalUrl = headers['x-ms-original-url']; + // SWA strips content-type headers from empty POST requests, but SK form actions require the header + // https://github.com/geoffrich/svelte-adapter-azure-swa/issues/178 + if (method === 'POST' && !body && !headers['content-type']) { + headers['content-type'] = 'application/x-www-form-urlencoded'; + } + /** @type {RequestInit} */ const init = { method,