【发布时间】:2017-01-06 19:22:39
【问题描述】:
有什么方法可以在 Chrome 中禁用 strict MIME type checking。
实际上我正在跨域发出 JSONP 请求。它在 Firefox 上运行良好,但是在使用 chrome 时,它在控制台中出现了一些错误。
拒绝执行来自 'https://example.com' 的脚本,因为它的 MIME 类型 ('text/plain') 不可执行,并且启用了严格的 MIME 类型检查。
它在 Mozilla 中完美运行.. 问题仅在 chrome 中出现
这是请求的响应标头..
Cache-Control:no-cache, no-store
Connection:Keep-Alive
Content-Length:29303
Content-Type:text/plain;charset=ISO-8859-1
Date: xxxx
Expires:-1
Keep-Alive:timeout=5
max-age:Thu, 01 Jan 1970 00:00:00 GMT
pragma:no-cache
Set-Cookie:xxxx
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options:nosniff
X-Frame-Options:SAMEORIGIN
解决我的想法:
外部设置 content-type 为application/javascript
【问题讨论】:
-
你见过类似的问题吗? stackoverflow.com/questions/17341122/…
-
@Rory McCrossan 是的......这个问题是指从 github 获取文件......它们是将文件导出为 zip 的替代解决方法......
-
您以纯文本形式发送的内容是什么?
-
它收到一个json..响应是这样的..
angular.callbacks._3({json_data}) -
我错过了你正在发送 JSONP;您需要使用正确的 MIME 类型:
application/javascript
标签: javascript jquery angularjs google-chrome