Azure / Azure/static-web-apps

Function response headers not preserved

Open
#618 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
346
Forks
67
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

I am calling an Azure Function that runs inside the Azure Static Web App instance from a React frontend that also runs inside the Azure Static Web App instance. This function sets custom response headers but these headers do not show up in the response inside the frontend (the response headers seem to be overwritten somehow). This behaviour only occurs when I deploy the Static Web App to Azure. When run locally, everything works fine.

Stripped down function code:

```javascript
import { AzureFunction, Context, HttpRequest } from '@azure/functions'

const testFunction: AzureFunction = async function (context: Context, req: HttpRequest) {
...

context.res = {
status: 200,
headers: { 'content-type': 'application/json', 'content-range': 0-1/2 },
...
}
}

export default testFunction
```

I can see the header `content-type` but not the header `content-range`.

**Expected behavior**

The headers set inside the function should be preserved in the response.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.