In FF and all, my javascript works fine. But in Chrome it gives this message:
Resource interpreted as script but transferred with MIME type text/plain.
I have checked all the script tags and they all have the MIME type="text/javascript"
. It even says so with jquery and jquery ui. What is wrong with Chrome?
What's the problem and the fix for this? Is it something I have to change in the 'options' of the browser or is it from the server, or do I have to tweak my code?
In your apache's httpd.conf, just add such a line:
Weird issue, but this helped me to solve my issue. Sometimes even the easiest things are hard to figure out...
Instead of using
/js/main.css
in my script-tag I usedjs/main.css
YES, it did actually make a difference. I'm sitting on WAMP / Windows and I didn't have a vhost but just used
localhost/<project>
If I reference to
/js/main.css
then I reference tolocalhost/css/main.css
and not tolocalhost/<project>/css/main.css
When you think of it, it's quite obvious but if someone stumbles upon this I thought I would share this answer.
In my case, the server was sending the correct
Content-Type
but with an incorrectContent-Encoding
. Make sure that you only setContent-Encoding: gzip
for gzipped resources. Also, after I fixed the headers in the server (in my case, Google Cloud Storage), I had to wait a few minutes to properly reflect the changes due to caching.If you are using AdonisJS (REST API, for instance), one way to avoid this is to define the response header this way:
For me, it only happened on some pages because I used
window.location
instead of$location.url(...);
This fixed my problem. Took a while to figure out :)The answer posted here by simon-sarris helped me.
Don't forget to restart your system after the changes.