css - 如何修复自定义字体的 CORS 错误?
问题描述
我上传的自定义字体未在 Firefox 或 Chrome 上显示,但它在 Safari 和移动设备上运行。我收到一个 CORS 错误“CORS 政策:没有 'Access-Control-Allow-Origin'”。
可能是样式表链接吗?
(链接 rel="stylesheet" type="text/css" href="http://go.pardot.com/l/752313/2019-06-15/pfv/752313/4021/1711_JKVABE.css")
这是该页面的链接:http: //go.pardot.com/l/752313/2019-06-07/g4s
@font-face {
font-family: 'Canela Web';
src: url('http://go.pardot.com/l/752313/2019-06-15/pfs/752313/4019/Canela_Regular_Web.eot');
src: url('http://go.pardot.com/l/752313/2019-06-15/pfs/752313/4019/Canela_Regular_Web.eot?#iefix') format('embedded-opentype'),
url('http://go.pardot.com/l/752313/2019-06-15/pfn/752313/4015/Canela_Regular_Web.woff2') format('woff2'),
url('http://go.pardot.com/l/752313/2019-06-15/pfq/752313/4017/Canela_Regular_Web.woff') format('woff');
font-weight: 400;
font-style: normal;
font-stretch: normal;
}
.Canela-Regular-Web {
font-family: 'Canela Web';
font-weight: 400;
font-style: normal;
font-stretch: normal;
}
解决方案
我有一个类似的问题。要修复此特定错误,CSP 应包括以下内容:
font-src 'self' data:;
因此,在 head 标签中应该设置这个元:
<meta http-equiv="Content-Security-Policy" content="connect-src * 'unsafe-inline'; font-src 'self' data:;">
推荐阅读
- stored-procedures - 使用存储过程透视表
- tfs - 是否可以从 TFS(或 Azure DevOps)导出/导入板配置
- grep - 显示不以一个或多个字母开头且不以一个或多个数字结尾的行
- node.js - 导出带有添加方法的模块返回对象
- reactjs - useEffect 更新后的本地状态行为
- arduino - 如何使用 Arduino Uno 在不同状态之间切换?
- python - 按索引访问 Python 列表
- mysql - 在 MySql 中将随机数据插入到表中
- mysql - 尽管没有冲突,但 MySQL 列权限会覆盖全局权限
- git - 我推送到某个存储库的 Git 分支未出现在 Azure DevOps 的“我的”列表中