解决chrome浏览器跨域请求报Refused to execute script from
在最近一次项目中有一个接口是JSONP接口,也就是允许跨域访问,在firefox中是可以正常访问,chrome中确报如下错
Refused to execute script from 'xxxxxxxxxx' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.找了半天才发现因为服务器端框架比较新,在响应头文件中加了如下参数,可以在浏览器调试器的网络中查看到
x-content-type-options:nosniff
这样chrome只能访问响应内容类型为如下的JSONP接口
"application/ecmascript"
"application/javascript"
"application/x-javascript"
"text/ecmascript"
"text/javascript"
"text/jscript"
"text/x-javascript"
"text/vbs"
"text/vbscript"那么只能由服务器端修改代码,手动设置内容为如上的一种
response.setContentType("text/javascript");//如果不这样设置 chrome浏览器无法调用
有任何问题请联系微信

如果您觉得我的文章给了您帮助,请为我买一杯饮料吧!以下是我的支付宝,意思一下我将非常感激!
相关推荐
86417413 2020-11-25
simonzhao0 2020-11-23
HappyBlog 2020-10-27
del 2020-10-21
ChromeDisaster 2020-10-11
svap 2020-08-25
simonzhao0 2020-08-17
shayuchaor 2020-08-17
yidaizongshi 2020-08-16
化风 2020-08-14
tiankele0 2020-07-29
maowenbei 2020-07-19
curiousL 2020-07-18
王练 2020-07-18
liuweiq 2020-07-08