Azure / Azure/static-web-apps

Global Header configuration is partially ignored

Open
#1,561 3 comments 2 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**

Azure Static Web Applications ignores certain headers in the `staticwebapp.config.json` globalHeaders setting.
Setting `X-Xss-Protection: ""` does not remove the headers like the documentation suggests [here](https://learn.microsoft.com/en-us/azure/static-web-apps/configuration). Additionally, I cannot add the `Permissions-Policy` header. Setting this key does not raise any errors or warnings during deployment, but does not show up in the response headers.

**To Reproduce**
Steps to reproduce the behavior:
1. Create a SWA and a basic react SPA
2. use the following `staticwebapp.config.json`:
```
{
"navigationFallback": {
"rewrite": "/index.html",
"exclude": ["/assets/*", "/images/*.{png,jpg,gif}", "/css/*"]
},
"globalHeaders": {
"X-Frame-Options": "DENY",
"Content-Security-Policy": "frame-ancestors 'none'",
"Permissions-Policy": "microphone=(), geolocation=()",
"X-Xss-Protection": ""
}
}
```
4. run `npx swa deploy --env production`
5. Inspect response headers and see missing headers

**Expected behavior**
the Permissions-Policy header should appear in the response header, and the X-Xss-Protection header should no longer be a part of the response

**Additional context**
Deployed using azure/static-web-apps-cli 2.0.1

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.