内容安全策略 style-src 拒绝在 Safari 中加载
Content Security Policy style-src refuses to load in Safari
使用 Safari 11.0 我在尝试加载我维护的网站上的 CSS 资源时收到错误消息。该页面在 Chrome 和 Firefox 中加载正常,过去在 Safari 中加载正常,所以我不确定如何解决它。我猜我需要修改 Content-Security-Policy
header。
来自 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
文件未加载且网站呈现不正确。
网站(通过 caddy 设置)的安全 header 是:
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
更改 Content-Security-Policy
header 值的 style-src
部分,使其变为 style-src 'self' https://****.com
。也就是说,将 https://****.com
中的 ****.com
替换为实际主机名。
使用 Safari 11.0 我在尝试加载我维护的网站上的 CSS 资源时收到错误消息。该页面在 Chrome 和 Firefox 中加载正常,过去在 Safari 中加载正常,所以我不确定如何解决它。我猜我需要修改 Content-Security-Policy
header。
来自 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
文件未加载且网站呈现不正确。
网站(通过 caddy 设置)的安全 header 是:
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
更改 Content-Security-Policy
header 值的 style-src
部分,使其变为 style-src 'self' https://****.com
。也就是说,将 https://****.com
中的 ****.com
替换为实际主机名。