Google Chrome + FireFox无法加载自定义字体(访问控制允许来源)

时间:2019-03-01 22:42:25

标签: css google-chrome firefox fonts

我相信是昨天,我的网站的自定义字体停止运行。现在,这些字体仅显示在Safari上,而Chrome和Firefox的throw访问控制则允许在各自的控制台上出现原始错误。 Chrome错误:

  

Access to font at 'https://blockheaddevdevdev--grify.repl.co/styles/font/wide.ttf' from origin 'https://blockheaddevdevdev.grify.repl.co' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Firefox错误:

  

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://blockheaddevdevdev--grify.repl.co/styles/font/wide.ttf. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).[Learn More]

Here is the font I am using Here is the CSS that applies the fonts to the page Here is the page that should run these custom fonts

2 个答案:

答案 0 :(得分:0)

您正在从此域导入style.css: https://blockheaddevdevdev--grify.repl.co

<link href="https://blockheaddevdevdev--grify.repl.co/styles/style.css" rel="stylesheet" type="text/css">

而不是:https://blockheaddevdevdev.grify.repl.co

这就是为什么您会收到跨域错误。

如果您修复了链接标记,就不会收到该错误。

答案 1 :(得分:0)

我将我的网址http://127.0.0.1/sitename/替换为http://localhost/sitename/,并且有效