Static files such as polyfills.js and logo.png return empty responses in (Angular) Azure Static Web App

Rik 20 Reputation points
2025-04-16T09:00:57.61+00:00

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

  1. Why are static files like polyfills.js and logo.png being served with empty content despite being excluded from the SPA fallback?
  2. Is there a reliable way to confirm that staticwebapp.config.json is being recognized and applied during deployment?
  3. 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

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,177 questions
{count} votes

Accepted answer
  1. Alekhya Vaddepally 1,670 Reputation points Microsoft External Staff Moderator
    2025-04-17T10:55:17.8966667+00:00

    Hi Rik, I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to accept the answer.
    ISSUE:
    Static files such as polyfills.js and logo.png return empty responses in (Angular) Azure Static Web App
    Solution:
    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

    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.