diff --git a/files/entry.js b/files/entry.js index 6f49bd2..230bb35 100644 --- a/files/entry.js +++ b/files/entry.js @@ -32,6 +32,11 @@ app.http('sk_render', { */ handler: async (httpRequest, context) => { if (debug) { + context.log( + 'Starting request', + httpRequest.method, + httpRequest.headers.get('x-ms-original-url') + ); context.log(`Request: ${JSON.stringify(httpRequest)}`); } @@ -68,6 +73,16 @@ app.http('sk_render', { function toRequest(httpRequest) { const originalUrl = httpRequest.headers.get('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 ( + httpRequest.method === 'POST' && + !httpRequest.body && + !httpRequest.headers.get('content-type') + ) { + httpRequest.headers.set('content-type', 'application/x-www-form-urlencoded'); + } + /** @type {Record} */ const headers = {}; httpRequest.headers.forEach((value, key) => { diff --git a/package-lock.json b/package-lock.json index e1d7654..162489f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "svelte-adapter-azure-swa", - "version": "0.21.0", + "version": "0.20.1", "license": "MIT", "dependencies": { "esbuild": "^0.19.9",