From d14aae1bd35a68ed6836db6277753f2e3619de1b Mon Sep 17 00:00:00 2001 From: Geoff Rich <4992896+geoffrich@users.noreply.github.com> Date: Sat, 13 Jul 2024 16:58:23 -0700 Subject: [PATCH 1/2] fix: work around SWA issue with empty form bodies (#179) * fix: work around SWA issue with empty form bodies * chore: more debug logs --- files/entry.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/files/entry.js b/files/entry.js index 857ce44..2ae126e 100644 --- a/files/entry.js +++ b/files/entry.js @@ -29,6 +29,12 @@ export async function index(context) { const request = toRequest(context); if (debug) { + context.log( + 'Starting request', + context?.req?.method, + context?.req?.headers?.['x-ms-original-url'] + ); + context.log(`Original request: ${JSON.stringify(context)}`); context.log(`Request: ${JSON.stringify(request)}`); } @@ -66,6 +72,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, From a86dff70b5aa4e8e6b6531f6fbb29906fa93910c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 13 Jul 2024 16:59:34 -0700 Subject: [PATCH 2/2] chore: release 0.20.1 (#180) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ package-lock.json | 2 +- package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81c4da1..fafb334 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +### [0.20.1](https://www.github.com/geoffrich/svelte-adapter-azure-swa/compare/v0.20.0...v0.20.1) (2024-07-13) + + +### Bug Fixes + +* work around SWA issue with empty form bodies ([#179](https://www.github.com/geoffrich/svelte-adapter-azure-swa/issues/179)) ([d14aae1](https://www.github.com/geoffrich/svelte-adapter-azure-swa/commit/d14aae1bd35a68ed6836db6277753f2e3619de1b)) + ## [0.20.0](https://www.github.com/geoffrich/svelte-adapter-azure-swa/compare/v0.19.1...v0.20.0) (2024-01-01) diff --git a/package-lock.json b/package-lock.json index ed42209..a1a5582 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "svelte-adapter-azure-swa", - "version": "0.20.0", + "version": "0.20.1", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 6775dac..901ddbc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "svelte-adapter-azure-swa", "description": "SvelteKit adapter for Azure Static Web Apps.", - "version": "0.20.0", + "version": "0.20.1", "main": "index.js", "type": "module", "scripts": {