Skip to content

Commit

Permalink
fix: work around SWA issue with empty form bodies
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffrich committed Jul 13, 2024
1 parent 9b4d834 commit bedd3b1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions files/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit bedd3b1

Please sign in to comment.