web.dev-从原点访问字体已被CORS策略阻止:no访问权利:访问权限控制。标题存在于请求的资源上

发布于 2025-02-06 05:34:06 字数 304 浏览 1 评论 0原文

我没有在网站上遇到此错误,而是在网上测试时。

这里有人说此代码将修复它:

    <IfModule mod_headers.c>
  <FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|font.css)$">
     Header set Access-Control-Allow-Origin "*"
  </FilesMatch>
</IfModule>

我将上面的代码放在.htaccess中,但Google仍然给出了错误

i get this errors not on my website but when i test it on web.dev in section "Best Practices" ... how can i fix that ?

Some here says this code will fix it :

    <IfModule mod_headers.c>
  <FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|font.css)
quot;>
     Header set Access-Control-Allow-Origin "*"
  </FilesMatch>
</IfModule>

I put the code above in my .htaccess but google still gives that error

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绾颜 2025-02-13 05:34:06

基于 Shaitana&amp; Stephen Ostermiller 的答案您可以将此规则添加到您的.htaccess

Header add Access-Control-Allow-Origin "*"

或更好的情况下,如果您指定了域值

Header add Access-Control-Allow-Origin "your-domain.example"

Based on shaitana & Stephen Ostermiller's answer you could add this rule to your .htaccess

Header add Access-Control-Allow-Origin "*"

Or better if you specified the domain value

Header add Access-Control-Allow-Origin "your-domain.example"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文