Azure / Azure/static-web-apps

Updating globalHeaders in staticwebapp.config.json does not apply if files are unchanged

Open
#905 6 comments 1 reaction 0 assignees View on GitHub
triaged
Dominant language
No language data
Stars
346
Forks
67
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

This is maybe wrong, but it seems right after some testing.

Steps to reproduce:

Setup a staticwebapp.config.json with some global headers, and create some static html

```json
"globalHeaders": {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, OPTIONS",
}
```

deploy to a staging environment using Static Web App Cli Deploy

```sh
swa deploy -a "./build" -n swa-echo3dweb-temp --swa-config-location "." --env headertesting
```

check that the headers are correct by inspecting in chrome dev tools

Change the globalHeaders, for instance add POST to Methods
```json
"globalHeaders": {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
}
```
deploy again, with no content changes otherwise.

Observe that the headers for the index.html file does not change. It will still show "Access-Control-Allow-Methods": "GET, OPTIONS", (no POST)

Change anyting in the index.html file.
Redeploy and see that the headers are updated.

THEN: Revert the changes in index.html and see that the headers are reverted to the original!

All this is tested in chrome with the dev-tools open and `disable-cache` checked ✅.

Deleting and re-creating the temporary environment does not matter.

**Expected behavior**

Updates to globalHeaders force a response change even if there is no content change / same etag in the deployed content.

**Device info (if applicable):**
- OS: Windows
- Browser Chrome
- Version 104
- Static Web App Cli `1.0.2`

**Additional context**
Add any other context about the problem here.

These changes were deployed with Static Web App Cli `1.0.2`

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.