Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty POST requests to an API have the content-type header removed #1512

Open
geoffrich opened this issue Jul 13, 2024 · 0 comments
Open

Empty POST requests to an API have the content-type header removed #1512

geoffrich opened this issue Jul 13, 2024 · 0 comments

Comments

@geoffrich
Copy link

Describe the bug

Empty POST requests to the API of an Azure Static Web App have the content-type header removed.

To Reproduce

repro

  • create an Azure Function in your SWA that handles POST requests
  • inspect the content-type header received by that function (either by logging or by returning the value)
  • if the POST request has no body, the content-type header is not present. This is despite the content-type header being present on the original request from the browser

live demo

Click "submit" on the empty form. The response from the Azure function shows that no content-type header was passed to the function handler. However, if you inspect the request sent from the browser, the content-type header was sent -- so something is removing the header before it gets to the Azure function.

image

Submitting the second form (which has a form body) does not strip the content-type header.

Expected behavior

I expect the Azure function to receive the same content-type header that was sent from the browser.

Device info (if applicable):
n/a

Additional context

I maintain an Azure SWA adapter for SvelteKit and this behavior caused this issue.

This appears to be SWA specific, instead of a more general Azure function problem. I deployed the same Azure function code to a standalone function and it did not remove the content-type header.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant