我正在尝试使用 Google 字体,我从来没有遇到过任何问题,但现在当我尝试在我的页眉上添加 CSS 文件时,我在控制台上收到此错误:
拒绝加载样式表 'http://fonts.googleapis.com/css?family=Whatever'
因为它违反了以下内容安全策略指令:"style-src ' self' '不安全内联'”
。
最佳答案
这里有两件事需要解决:
- 为 Google 字体链接使用 https (
https://fonts.googleapis.com/css?family=Whatever
) - 授权
https://fonts.googleapis.com
在style-src
指令和https://fonts.gstatic.com
在font-src
指令:"style-src 'self' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com"
关于html - Google 字体违反内容安全政策,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33984908/