简体   繁体   English

如何解决错误“未在脚本名称加载脚本”,因为在给出“X-Content-Type:nosniff”时不允许使用非脚本MIME类型

[英]How to address error "Did not load script at 'script name' because non script MIME types are not allowed when 'X-Content-Type: nosniff' is given

I have a fairly simple Angular 1.x app that was working fine until i upgraded to Safari 11. Now, it doesn't work because almost all of the js files are blocked. 我有一个相当简单的Angular 1.x应用程序工作正常,直到我升级到Safari 11.现在,它不起作用,因为几乎所有的js文件都被阻止。

The same was true for CSS files, but removing the "rel" attribute and adding type="text/css" fixed the CSS issues. CSS文件也是如此,但删除“rel”属性并添加type =“text / css”修复了CSS问题。

For the JS files, I've made sure to add type="text/javascript" to the script tags. 对于JS文件,我确保在脚本标记中添加type =“text / javascript”。 I also just tried adding ./ to the beginning of the src's for giggles and they still won't load. 我也尝试将./添加到src的开头为giggles而且仍然无法加载。

Does anyone know how to fix this? 有谁知道如何解决这一问题?

Thanks, Wayne 谢谢,韦恩

I want to just delete the question but I hope maybe this answer will still be helpful to someone. 我想删除这个问题,但我希望这个答案对某人有用。

So, my problem was actually that I had a bad clone of my project and it was missing files! 所以,我的问题实际上是我的项目有一个糟糕的克隆,它丢失了文件!

However, for anyone having the same issue: 但是,对于有同样问题的人:

ensuring that type="text/css" for stylesheets and type="text/javascript" did fix the issue. 确保样式表的type =“text / css”和type =“text / javascript”确实解决了问题。 (for the files that actually existed) (对于实际存在的文件)

Please make sure that a response header with the name X-Content-Type or X-Content-Type-Optionas has the text/javascript value instead of nosniff . 请确保名称为X-Content-TypeX-Content-Type-Optionas的响应标头具有text/javascript值而不是nosniff

It is simple to make a workaround locally using Charles Proxy Rewrite tool 使用Charles Proxy Rewrite工具在本地进行解决方法很简单

在此输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Node.js路由错误:给出'X-Content-Type:nosniff'时,不允许脚本MIME类型 - Node.js route error: script MIME types are not allowed when 'X-Content-Type: nosniff' is given 拒绝将 *path_to_bundle* 作为脚本执行,因为给出了“X-Content-Type: nosniff”,并且它的 Content-Type 不是脚本 MIME 类型 - Refused to execute *path_to_bundle* as script because “X-Content-Type: nosniff” was given and its Content-Type is not a script MIME type 由于 MIME 类型 (“text/html”) 不匹配 (X-Content-Type-Options: nosniff),来自“http://localhost:3000/script.js”的资源被阻止 - The resource from “http://localhost:3000/script.js” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff) 由于不允许的 MIME 类型,无法加载模块脚本 - Failed to load module script because of a disallowed MIME type 加载模块脚本失败:应为 JavaScript 模块脚本,但服务器响应 MIME 类型为“”。 (我做了类型模块) - Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "". (I did type module) 加载模块脚本失败:服务器以非 JavaScript、CSS MIME 类型“text/x-scss”响应 - Failed to load module script: The server responded with a non-JavaScript, CSS MIME type of “text/x-scss” NGINX:X-Content-Type-Options nosniff导致错误的资源/ MIME类型 - NGINX: X-Content-Type-Options nosniff results in wrong resource/MIME-types 错误:由于 MIME 类型(“text/html”)不匹配而被阻止(X-Content-Type-Options: nosniff) - Error: Blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff) 来自 Firefox 的错误:MIME 类型(“text/plain”)不匹配(X-Content-Type-Options:nosniff) - Error from Firefox: MIME type (“text/plain”) mismatch (X-Content-Type-Options: nosniff) 加载模块脚本失败:服务器以非 JavaScript MIME 类型“”响应。 强制执行严格的 MIME 类型检查 - Failed to load module script: The server responded with a non-JavaScript MIME type of “”. Strict MIME type checking is enforced
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM