We are hosting a static Angular 18 application on Azure Static Web Apps (SWA). During runtime, we have noticed that certain static files - specifically polyfills.js
and the logo.png
image - are being returned with HTTP 200 responses, but with an empty body (Content-Length: 0
) and the wrong content type (Content-Type: text/plain
).
These files are present in the build output (dist/
) and are deployed using swa deploy
. However, when accessing them through the browser or via fetch requests, the response contains no content.
Configuration
swa deploy
dist
staticwebapp.config.json
is included with the following content:{
"navigationFallback": {
"rewrite": "/index.html",
"exclude": [
"/assets/*",
"/*.js",
"/*.css",
"/*.ico",
"/*.png",
"/*.svg",
"/*.webmanifest"
]
},
"mimeTypes": {
".js": "application/javascript",
".json": "application/json"
}
}
The config file is copied to the dist/
folder and verified to be deployed alongside the application without errors.
Troubleshooting Attempts
swa start
also works as expected.Content-Length
is 0This strongly suggests that the problem lies in how the production SWA environment interprets or applies the configuration — not in the application code or build artifacts.
Temporary Workaround
We have temporarily resolved the issue by externally hosting the problematic files via Gitlab Pages. However, we would prefer to serve all assets directly from Azure SWA as intended.
Questions
polyfills.js
and logo.png
being served with empty content despite being excluded from the SPA fallback?staticwebapp.config.json
is being recognized and applied during deployment?/assets/
directory in Azure Static Web Apps?I also posted this question on the Microsoft forum
The problem wasn't necessarily with the configuration of the Angular app or the SWA settings. But it was simply that we are using Enterprise-grade edge for the SWA, and somehow its cache was not cleared during the deployment of an Angular app update even though it should happen.
Clearing Enterprise-grade edge cache from the Azure portal resolved the issue:
https://portal.azure.com -> Open relevant Static Web App -> Enterprise-grade edge
-> Purge