内容安全策略style-src拒绝在Safari中加载

时间:2017-10-01 20:45:26

标签: safari http-headers content-security-policy

使用Safari 11.0我在尝试在我维护的网站上加载CSS资源时收到错误。该页面在Chrome和Firefox中正常加载,并且用于在Safari中正常加载,因此我不确定如何解决它。我猜我需要修改Content-Security-Policy标题。

Safari控制台的具体错误是Refused to load https://****.com/css/styles.css because it does not appear in the style-src directive of the Content Security Policy.因此,styles.css文件无法加载,网站呈现错误。

网站的安全标头(通过球童设置)是:

Content-Security-Policy default-src 'self' https:; script-src 'self'; style-src 'self'; object-src 'none' Content-Type text/html; charset=utf-8 Referrer-Policy strict-origin Server Caddy Strict-Transport-Security max-age=31536000; includeSubDomains; preload

1 个答案:

答案 0 :(得分:2)

更改style-src标头值的Content-Security-Policy部分,使其改为style-src 'self' https://****.com。也就是说,将****.com中的https://****.com替换为实际主机名。