Angular - Failed to load module script: - mime-types

I have angular 8 front end application in production and its 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.
This issue is happening only in production build that too not always , able reproduce only sometimes.
main-es2015.fcc7123d15fd9c113b00.js:1
vendor-es2015.d8d7d81cc2b06ece8c91.js:1
How do i fix it.?

Are you using serviceWorker?
If so you have to add inside angular.json "serviceWorker": true for the configuration that you are using.

I would like to share my experience with the same issue I was facing in the organization where I'm working.
I had an Angular 9 application and when I deployed to Stage environment, I got three errors in my console which showed as "module not loaded due to Mime type". This was working fine in all other environment and after much struggle, it was found that the files under the website were not having access. E.g. When you deploy an Angular application, you will get index.html file and many other js files. The website had permission issues. The site was hosted in the Rackspace and the FireWall was not configured to have access to the files right under the website.
Once the below access was provided, the app started working.
/assets*
/*.css
/*.js
/*.ico
/*.html
The only difference I see with your problem is that you have mentioned it is working sometimes.
There is another post Blocked because of a disallowed MIME type (“text/html”) : Angular 8 deployed on tomcat 9.0.30 fails to serve the assets try the solution based on base reference as those js files are not served/loaded
I hope this might help someone.

Related

React S3+Cloudfront Cache Invalidation issues

For the project, we tried to deploy the front-end React static files by using AWS S3 + cloudfront.
It worked at the first time, but there was an issue that even though we updated with new build, some of the contents were not updating.
For the updates, we tried using invalidation method in Cloudfront and set /index.html. However, it didn't work properly and didn't load the updated build file so we also tried to invalidate assets files and met this problem.
Failed to load module script: Expected a JavaScript 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
Is there a way to cancel the invalidation that we already did or fix this issue?

Upgrade webapp Grails 2 to Grails 3 : cannot see index.html anymore

I just updated my Grails 2 webapp project (Grails back end and Angular as front-end) to Grails 3.
I moved all the web-app folder from my grails2 project to src/main/webapp (tried also in src/main/resources) folder.
Now running bootRun -->http://localhost:8080/ up and running
Trying to access http://localhost:8080/index.html gets an error...
What I meant is that I cannot access to my HTML files. I get an error : "This application has no explicit mapping for /error, so you are seeing this as a fallback." because I commented the error redirection in URLMappings. However, I do not understand why with Grails 3 my index.html is not accessible anymore while it worked ith Grails2 with the same configuration of URLMappings.
Surely missing something but have no clue what ?
Many thanks.

angular js path returns 404 error when https is used

Please keep in mind, I have not worked with angular JS, nor did I write the code that is causing the error.
I am getting an 404 error on this path:
https://www.helivalues.com/Su6UsWuf/bb/option/mfg/all
but not this path:
http://www.helivalues.com/Su6UsWuf/bb/option/mfg/all
It was noticed that when a user views a certain page in https, the drop down does not load options. Angular Js makes a call to the path mention above which is not an actually file but is used by a php file that based on this path, has a switch that fills in the drop down.
Any ideas on how to get the https version to work? This is on a joomla site and I do have access to the htaccess file if needed. I really just need it to work for a few months while I work on building a new site.
Thanks!
Angularjs is not the issue. Your webserver (Apache/2.2.15 (SuSE) Server at www.helivalues.com Port 443) states the file can not be found. So it looks like something is misconfigured with your apache site.

HTML5Mode, AngularJS and Grunt Build Control

Hoping someone can answer this because I'm struggling...
I have an angular js app that was build with the yo-angular generator. All works fine with deploying through grunt build control, as long as I'm not using the #-free "html5mode."
However, once I enable html5mode to remove the # from my routing and then deploy, my app on github pages doesn't point to the correct source for its scripts and such... For instance, I'm getting a 404 error because it's looking for http://{{user name}}.github.io/scripts/{{name of file}}, instead of http://{{user name}}.github.io/{{app name}}/scripts/{{name of file}}
How can I get it to point to the correct directory?
Hope this makes sense. I'll share more if needed!
You also need to configure the server. The configuration change will depend on what technology you are using to host the app on the server. How to configure your server to work with html5mode

NetworkError: 404 Not Found on firefox

We have a gwt app deployed on gae for java. The app runs fine in google chrome but fails with below exception on ie and firefox
NetworkError: 404 Not Found - http://www.sakshum.org/adminmodule/67883654A8944A4C561CF25763FB1D79.cache.html
based on Setup a GWT Project correctly with SVN and Eclipse we have excluded the files in adminmodule directory to upload to app engine.
Please advise what is reason for it to fail and how to make it working.
The ignored patterns are:
.svn
*.bak
classes/
thumbs.db
*.class
.gwt*
gwt-unitCache/
deploy/
war/adminmodule/
war/sakshumwebgae/
sakshumweb/war/WEB-INF/deploy/adminmodule/
sakshumweb/war/sakshumwebgae/
.bin
*.orig
You will get 404. HORROR!!!!
Currently only /deploy/ folder can be ignored and not war/gwtmodule.
All the gwt generated scripts are in war/gwtmodule and you need to upload them per compilation into appengine.
These are generated every build in compilation phase and hence are not checked into svn.
They need to be in deployment folder for APP Engine.
I suggest you go through the GWT teams excellent document for App Engine with GWT https://developers.google.com/web-toolkit/doc/latest/tutorial/appengine
Edit -
<modulename>.nocache.js loads <longnumeric>.cache.html based on browser * language permutation. GWT compiles your java code to create the <modulename>.nocache.js and the relevant cache.html files. cache and nocache indicates whether browser is supposed to cache or not cache the file.
You will have the .nocache.js script reference in your html file for the gwtapp.
It's normal for the GWT compiler to build different javascript files for each permutation. A permutation is for a specific user-agent (browser, eg ie9 gecko (ff), webkit (chrome/safari)) and language (English, French). So you've correctly uploaded all the output files for the chrome browser, presumably in English. It would seem, as you say, that you're filtering out other files from uploading, and that some of those files are requested when using a different permutation for Firefox in English. You should try not to filter those files.

Resources