Resource blocked due to MIME type mismatch (X-Content-Type-Options: nosniff)

匿名 (未验证) 提交于 2019-12-03 02:54:01

问题:

I am developing a web page using JavaScript and HTML, everything was working good when I have received this list of errors from my HTML page:

The resource from “https://raw.githubusercontent.com/dataarts/dat.gui/master/build/dat.gui.min.js”   was blocked due to MIME type mismatch (X-Content-Type-Options: nosniff). The resource from “https://raw.githubusercontent.com/mrdoob/three.js/dev/build/three.js” was   blocked due to MIME type mismatch (X-Content-Type-Options: nosniff). The resource from “https://raw.githubusercontent.com/mrdoob/three.js/master/examples/js/renderers/CanvasRenderer.js”   was blocked due to MIME type mismatch (X-Content-Type-Options: nosniff). The resource from “https://raw.githubusercontent.com/mrdoob/three.js/master/examples/js/renderers/Projector.js”   was blocked due to MIME type mismatch (X-Content-Type-Options: nosniff). The resource from “https://raw.githubusercontent.com/mrdoob/three.js/dev/build/three.js” was   blocked due to MIME type mismatch (X-Content-Type-Options: nosniff). 

These errors appeared after an automatic browser update (Mozilla Firefox), may be something has been changed in the set up. Do you know any way to solve this problem?

回答1:

Check if the file path is correct and the file exists - in my case that was the issue - as I fixed it, the error disappeared



回答2:

This can be fixed by changing your URL, example bad:

https://raw.githubusercontent.com/svnpenn/bm/master/yt-dl/yt-dl.js Content-Type: text/plain; charset=utf-8 

Example good:

https://cdn.rawgit.com/svnpenn/bm/master/yt-dl/yt-dl.js content-type: application/javascript;charset=utf-8 

rawgit.com is a caching proxy service for github. You can also go there and interactively derive a corresponding URL for your original raw.githubusercontent.com URL. See its FAQ



回答3:

check your path ,this error will come if file was not exist into given path.



回答4:

This might be because the browser cannot access a file. I stumbled with this type of error when creating application with node.js. You can try to directly request the script file (copying and pasting url) and see if you can retrieve it. You can see then what the real problem is. It can be because of permission of folder in which the file is located, or browser just cannot find it due to incorrect path to it. In node.js, after specifying route to file, all works.



回答5:

I've solved this problem by changing charset in js-files from UTF-8 without BOM to simple UTF-8 in Notepad++



回答6:

In my case i just missed the slash "/" after get_template_directory_uri() so resulted / generated path was wrong:

My Wrong code :

wp_enqueue_script( 'retina-js', get_template_directory_uri().'js/retina.min.js' );  

My Corrected Code :

wp_enqueue_script( 'retina-js', get_template_directory_uri().'/js/retina.min.js' ); 


回答7:

Are you using express?

Check your path(note the "/" after /public/):

app.use(express.static(__dirname + "/public/")); 

//note: you do not need the "/" before "css" because its already included above:

rel="stylesheet" href="css/style.css 

Hope this helps



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!