我正试图通过Firebase加载字体(位于cdn.domain.co.uk
),但Chrome由于CORS
而阻止了响应,并给出以下错误:
Font from origin 'https://cdn.domain.co.uk' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://domain.co.uk' is therefore not allowed access.
有办法解决这个问题吗?
请注意同样有此问题的任何人:阅读文档!
将以下内容应用于您的firebase.json
,并相应地更改值。
"headers": [ {
"source" : "**/*.@(eot|otf|ttf|ttc|woff|font.css)",
"headers" : [ {
"key" : "Access-Control-Allow-Origin",
"value" : "*"
} ]
} ]
Firebase提供的完整文档:https://www.firebase.com/docs/hosting/guide/full-config.html