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.
1,178 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Grmacjon-MSFT 19,226 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

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.