After deploying an Angular app on Heroku, a blank page is shown when URL is reached and console is showing MIME type errors.
error is:
Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
One possible explanation for the error:
You get this behavior when you deploy your app into a subfolder, not directly on your base-URL. The HTML is found when you go to www.yourbase.com/yoursubfolder/index.html
, but as the angular app fetches other resources from www.yourbase.com/resource.css
instead of from www.yourbase.com/yoursubfolder/resource.css
and your webserver probably serves some default page (maybe your www.yourbase.com/index.html
) the content of your CSS becomes the content of that HTML page. That would explain the error.
To fix it build your angular app with:
ng build --prod --base-href yoursubfolder
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With