0

I’m working on an Angular project, and I’ve run into an issue when deploying to the production environment.

After deployment, I see this error in the browser console for a while:

Failed to load module script: Expected a JavaScript-or-Wasm module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.

However, when I deploy the same build to the staging environment, everything works fine and I don’t see this error.

Why does this happen only on production, and how can I fix it?

It seems to happen right after deploying to production, then starts working after some time.

6
  • Please provide enough code so others can better understand or reproduce the problem. Commented Sep 2 at 9:29
  • What does your browser's dev tools' network tab tell you? What response is being returned when requesting the module script? Commented Sep 2 at 9:33
  • @Robby Cornelissen I can see that chunk-TPAECIHS.js is returning a 200 OK, but the response body is actually an HTML document (looks like the fallback index.html). That seems to be why the browser complains about the MIME type mismatch. Commented Sep 2 at 10:00
  • So either files are missing you you have reverse proxy setup incorrectly. Do you use CDN? Commented Sep 2 at 12:21
  • You need to enable detailed logging on your server/load balancer/proxy to see what requests are coming in, and what it chooses to send in response. Too many possible causes at this point, and hard to say anything more without knowing the actual infrastructure setup. You're in for a debugging session... Commented Sep 2 at 15:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.