禁用Chrome严格的MIME类型检查 [英] Disable Chrome strict MIME type checking
问题描述
有什么方法可以在Chrome中禁用严格的MIME类型检查
。
$ b
它在Mozilla中完美运行..问题仅出现在chrome中
以下是请求的响应头。
缓存控制:no-cache,no-store
连接:Keep-Alive
Content-Length:29303
Content-Type:text / plain; charset = ISO-8859-1
日期:xxxx
过期时间:-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
解决方法我认为:
将内容类型从外部设置为 application / javascript
解决方案
服务器应该为JSONP application / javascript
使用正确的MIME类型进行响应,并且您的请求应该告诉jQuery您正在加载JSONP dataType:'jsonp'
请参阅这个答案的进一步细节!
您也可以看看这个,因为它解释了为什么加载 .js 文件与
text / plain
不起作用。
Is there any way to disable strict MIME type checking
in Chrome.
Actually I'm making a JSONP request on cross domain. Its working fine on Firefox but, while using chrome its giving some error in console.
Refused to execute script from 'https://example.com' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.
Its working perfectly in Mozilla.. Issue is arising in chrome only
Here are the response Headers of the request..
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
Workaround what i think :
Externally setting content-type to application/javascript
The server should respond with the correct MIME Type for JSONP application/javascript
and your request should tell jQuery you are loading JSONP dataType: 'jsonp'
Please see this answer for further details !
You can also have a look a this one as it explains why loading .js
file with text/plain
won't work.
这篇关于禁用Chrome严格的MIME类型检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!