繁体   English   中英

带有Google字体的Webfont加载程序未使用https

[英]Webfont loader with Google Fonts is not using https

我在网站上使用webfont loader加载字体,并具有以下设置:

HTML

<script src="https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js" integrity="sha384-pvXSwSU09c+q9mPyY++ygUHWIYRoaxgnJ/JC5wcOzMb/NVVu+IDniiB9qWp3ZNWM" crossorigin="anonymous"></script>

JS

WebFont.load({
  google: {
    families: ['Libre Franklin']
  }
});

然后在我的.htaccess ,将样式表的源设置为内容安全策略的一部分,如下所示:

style-src 'self' https://fonts.googleapis.com;

但是,当网站加载字体时,它使用的是http://字体来源,因此CSP阻止了它,并且我在控制台中收到此错误消息:

Refused to load the stylesheet 'http://fonts.googleapis.com/css?family=Libre+Franklin' because it violates the following Content Security Policy directive: "style-src 'self' https://fonts.googleapis.com".

如何确定网站正在加载样式表的https://版本?

图书馆webfonts.js使用location.protocol调整请求的httphttps时,您的项目在域下https将变成https

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM