Azure static web app unable to server javascript module

Daniel Pinfold 0 Reputation points
2023-10-26T20:44:03.8566667+00:00

I have a react app deployed to a static web app. My repo is in github and all builds are successful but when i view my app i am unable to view any javascript/react content. Only static text. Also in the console I get the following error "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "application/octet-stream". Strict MIME type checking is enforced for module scripts per HTML spec."

How do i configure my static web app to serve javascript content. Thanks.

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Grmacjon-MSFT 19,466 Reputation points Moderator
    2023-11-01T23:50:38.95+00:00

    Hi @Daniel Pinfold , we are sorry to hear you're facing this issue.

    Here are the detailed steps to configure a static web app deployed React app to serve JavaScript content properly

    • Ensure your React app is being built correctly and artifacts are generated in the /build folder that gets deployed. Test locally.
    • Add a mime-types.json file to the client folder to specify JavaScript mime-type
    • Validate the build artifacts contain your JS bundles with the .js extension and not something like .txt.
    • Check the App Service logs in Kudu for any errors processing the JavaScript files during deployment.
    • Enable diagnostics logging and trace failed requests to see how JavaScript files are handled.

    If the issue persists after trying these steps, please let us know.

    -Grace

    0 comments No comments

  2. Pihlajamäki, Joni 0 Reputation points
    2025-10-24T10:32:39.6166667+00:00

    I had the same problem and reason was wrong configuration in .yml file in githubs project folder .github/workflows/azure-static-web-apps-your-page-name-1234.yml

    i changed row:

    output_location: "/" # Built app content directory - optional

    to (dist build folder)

    output_location: "dist" # Built app content directory - optional

    0 comments No comments

Your answer

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