Static files such as polyfills.js and logo.png return empty responses in Azure Static Web Apps
Description
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
- Framework: Angular 18
- Deployment method:
swa deploy
- Output directory:
dist
- Functions/API: Not used
-
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
- On our acceptance SWA environment, the issue does not occur — static files are served correctly.
- Local testing with
swa start
also works as expected.
- Rebuilding all (self published) Angular packages and creating a fresh application build does not resolve the issue.
- Directly accessing the files through their correct path does return a 200 OK response, but also then the
Content-Length
is 0
This 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
- Why are static files like
polyfills.js
and logo.png
being served with empty content despite being excluded from the SPA fallback?
- Is there a reliable way to confirm that
staticwebapp.config.json
is being recognized and applied during deployment?
- Are there known limitations or issues with serving static files from the root or
/assets/
directory in Azure Static Web Apps?
I also posted this question on StackOverflow