Closed brmi closed 6 years ago
Hi, this shouldn't normally happen. Sorry you're running into it! This is almost certainly s problem with your site's code not gatsby itself. If you do identify what the cause is and it seems like something Gatsby can fix then please open another issue.
@KyleAMathews How can I set the mime types for my script tags in index.html without modifying index.html directly? Tried this but doesn't work:
{
resolve: `gatsby-plugin-netlify`,
options: {
headers: {
"/*.js": [
"Cache-Control: public, max-age=0, must-revalidate",
"Content-Type: text/javascript"
],
},
},
},
Here's the fix in case anyone is wondering:
{
resolve: `gatsby-plugin-netlify`,
options: {
mergeLinkHeaders: false,
mergeCachingHeaders: false
},
},
Hi @brmi,
I got the same issue, but setting the mergeLinkHeaders
and mergeCachingHeaders
options on gatsby-netlify-plugin
doesn't seem to solve it. Can you think of anything else I could try to set the correct headers for *.js files? Do you additionally set any options on the plugin to set/ transform headers?
Edit: My error looks slightly different
The resource from <URL> was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).
also the *.js files are never loaded, even after reloading the page
This is not a Gatsby issue. It's your configuration in Netlify.
Netlify is returning an HTML page instead of JS or other resources.
In my case, it is returning Netlify's password protected HTML page instead of JS file, although I provided the password on the first page. It seems that the cookies are not passed correctly to other HTTP requests.
@brmi solution worked for me. Essential is that you definitely need to clear browser cache data after fixing. Otherwise you will still see the problem even though its theoretically gone.
Still dont get why Netlify responds with a wrong MIME or with wrong content (?) alltogether for a JS request behind a PW protected site after authenticating.
bonjour, j'ai le meme problème, mon site fonctionne bien localement mais lorsque je le deploy sur render ,il ya des pages que lorsque je rafraichit rien ne s'affiche. et les erreurs données par la console sont les suivantes: Refused to execute script from 'https://maisonalouer.onrender.com/singleImage/static/js/main.f545ef54.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.
Failed to load resource: the server responded with a status of 404 ()
aidez moi svp merci.
Description
On first load of my page, I always get this error:
Refused to execute script from '<URL>' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
The result is a lot of my javascript does not work at all. If I reload the page, it works perfectly. This only happens in production via Netlify.Steps to reproduce
On production build, load the page the first time.
Expected result
The javascript on the page should work and there should be no console errors.
Actual result
The javascript does not work and I get the above error, only on first page load.
Environment
System: OS: macOS High Sierra 10.13.6 CPU: x64 Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz Shell: 3.2.57 - /bin/bash Binaries: Node: 8.9.0 - /usr/local/bin/node Yarn: 1.1.0 - /usr/local/bin/yarn npm: 5.5.1 - /usr/local/bin/npm Browsers: Chrome: 67.0.3396.99 Firefox: 61.0.1 Safari: 11.1.2 npmPackages: gatsby: ^1.9.250 => 1.9.277 gatsby-link: ^1.6.40 => 1.6.46 gatsby-plugin-netlify: ^1.0.19 => 1.0.21 gatsby-plugin-react-helmet: ^2.0.11 => 2.0.11 gatsby-plugin-react-svg: ^1.1.1 => 1.1.1 gatsby-plugin-sass: ^1.0.26 => 1.0.26 gatsby-source-filesystem: ^1.5.36 => 1.5.39 gatsby-transformer-yaml: ^1.5.17 => 1.5.18 npmGlobalPackages: gatsby-cli: 1.1.58
File contents (if changed)
gatsby-config.js
:package.json
:gatsby-node.js
: N/Agatsby-browser.js
: N/Agatsby-ssr.js
: N/A