Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mime error with Angular 8 in Firebase Hosting

I have an Angular 8 app that is being hosted on Firebase and is being ran on the client side by: Go-Astilectron (Astilectron 0.30 and Electron 4.0.1).

The thing is that I am getting the error below in some of my clients (it happens just as the Angular code is loading, so the Astilectron just displays a blank page):

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.
main-es2015.5a90aaf45a8347384655.js:1 

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.

In some cases we managed to solve this by just reloading the page, but in others no matter what I do, the page doesn't load.

I've done some research and found that this might be releated to the application registering a service worker, but this is not my case.

Also, since I am servince a static site using Firebase Hosting, I didn't made any MIME configurations.

Can anyone help me?

like image 946
Felipe Avatar asked Jul 05 '19 15:07

Felipe


2 Answers

Be sure that in index.html the head includes:

<base href="/">

See: https://github.com/angular/angular-cli/issues/10325#issuecomment-399329033

This error also occurs when running Python servers on Windows machines where the Registry mime types are not set correctly.

See: https://github.com/pallets/flask/issues/1045#issuecomment-42202749

like image 121
Christopher Peisert Avatar answered Oct 17 '22 14:10

Christopher Peisert


I had this issue.

Go to angular.js and check the value of "outputPath". If it's set to something like "dist/your-project-name" try changing it to "dist/", redeploy and then do a hard refresh (Ctrl+F5) of your site.

like image 45
alexania Avatar answered Oct 17 '22 15:10

alexania