Skip to content

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

@geoffrich

Description

@geoffrich

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions