【问题标题】:Google Chrome + FireFox not loading custom fonts (access-control-allow-origin)Google Chrome + FireFox 未加载自定义字体(访问控制允许来源)
【发布时间】:2019-07-23 23:58:29
【问题描述】:

我相信昨天我的网站的自定义字体停止运行。现在,字体仅在 Safari 上显示,而 Chrome 和 Firefox 将访问控制允许原始错误发送到各自的控制台。 铬错误:

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

【问题讨论】:

    标签: css google-chrome firefox fonts


    【解决方案1】:

    您正在从该域导入您的 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

    这就是你得到一个跨域错误的原因。

    如果你修复了链接标签,你不应该得到那个错误。

    【讨论】:

    【解决方案2】:

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

    【讨论】:

    • 被 CORS 阻止了吗?如果不是,这可能是错误的线程。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-10
    • 2016-01-05
    • 1970-01-01
    • 2012-07-04
    • 2016-01-02
    • 2017-12-15
    相关资源
    最近更新 更多