如题,程序在Chrome,Opera中执行不了JavaScript,出现错误:
Refused to execute script from 'http://example.com/info?no=31&magic=1184' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
在Firefox,IE,Safari中没问题。
查了一下,貌似是 http header 的 X-XSS-Protection 设置问题。改了一下代码:
def info
response.headers['X-XSS-Protection'] = '0'
# Other logic
end
再次运行,Chrome中的header是:
X-XSS-Protection:1; mode=block
X-XSS-Protection:0
Firefox中的header是:
X-XSS-Protection 0, 1; mode=block
X-XSS-Protection:1; mode=block 是Nginx中的设置,即使拿掉,在Chrome中还是不能正常执行脚本代码,什么原因呢?
Refused to execute script from 'http://example.com/info?no=31&magic=1184' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
在Firefox,IE,Safari中没问题。
查了一下,貌似是 http header 的 X-XSS-Protection 设置问题。改了一下代码:
def info
response.headers['X-XSS-Protection'] = '0'
# Other logic
end
再次运行,Chrome中的header是:
X-XSS-Protection:1; mode=block
X-XSS-Protection:0
Firefox中的header是:
X-XSS-Protection 0, 1; mode=block
X-XSS-Protection:1; mode=block 是Nginx中的设置,即使拿掉,在Chrome中还是不能正常执行脚本代码,什么原因呢?