我怎样才能解决“缺失跨域资源共享(CORS)响应头”webfont问题? [英] How can I fix the 'Missing Cross-Origin Resource Sharing (CORS) Response Header' webfont issue?

查看:721
本文介绍了我怎样才能解决“缺失跨域资源共享(CORS)响应头”webfont问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因字体已经停止呈现在我的网站。这些字体存储在本地,在同一台服务器站点上。

我抬头的问题,这似乎是一个缺少跨域资源共享(CORS)响应头,但我无法理解这种情况的解决方案。

所有的各种网站说,要做的就是用:访问控制 - 允许 - 产地:*

但正如我主要的前端,我不知道在哪里把它。这是不是我的主机可以帮助?

我能做些什么来解决这个问题?

编辑:

该网站的问题是: http://cyclistinsuranceaustralia.com.au/

电话号码,例如,在右上角应该是自由的字体,但它默认为影响。

在控制台中,我得到了错误:

  

从原点 http://www.cyclistinsuranceaustralia.com.au 字体已被阻止加载由跨域资源共享方针:访问控制 - 允许 - 原产地头的值 http://www.cyclistinsuranceaustralia.com.au '不等于于所提供的原点。原产地 http://cyclistinsuranceaustralia.com.au ,因此不允许访问。

我联系我的主人说,谁放:

 访问控制 - 允许 - 起源http://www.cyclistinsuranceaustralia.com.au
 

在我的.htaccess文件,但是这并没有什么变化。

解决方案

在你的HTML您设置了基地的标签:

 <基地的HREF =htt​​p://www.cyclistinsuranceaustralia.com.au/>
 

  1. 删除行从您的HTML,如果你不需要它。这应该使字体从 http://cyclistinsuranceaustralia.com.au 观察工作。
  2. 您可能会需要重定向 http://www.cyclistinsuranceaustralia.com.au 到的 http://cyclistinsuranceaustralia.com.au

For some reason fonts have stopped rendering on my sites. The fonts are stored locally, on the same server as the site.

I looked up the problem and it seems to be a Missing Cross-Origin Resource Sharing (CORS) Response Header but I cannot understand the solution for this.

All the various sites say to do is to use: Access-Control-Allow-Origin:*

But as I'm primarily front end I do not know where to put it. Is this something my host can help with?

What can I do to fix the issue?

EDIT:

the site in question is: http://cyclistinsuranceaustralia.com.au/

The phone number, for example, at the top right should be Bebas font but it is defaulting to Impact.

In the console, I get the errors:

Font from origin 'http://www.cyclistinsuranceaustralia.com.au' has been blocked from loading by Cross-Origin Resource Sharing policy: The 'Access-Control-Allow-Origin' header has a value 'http://www.cyclistinsuranceaustralia.com.au' that is not equal to the supplied origin. Origin 'http://cyclistinsuranceaustralia.com.au' is therefore not allowed access.

I contact my host who said to put:

Access-Control-Allow-Origin "http://www.cyclistinsuranceaustralia.com.au"

in my .htaccess file but this has no change.

解决方案

In your HTML you have set a "base" tag:

<base href="http://www.cyclistinsuranceaustralia.com.au/">

  1. Delete that line from your HTML if you don't need it. This should make the fonts work when viewed from http://cyclistinsuranceaustralia.com.au.
  2. You'll probably need to redirect http://www.cyclistinsuranceaustralia.com.au to http://cyclistinsuranceaustralia.com.au

这篇关于我怎样才能解决“缺失跨域资源共享(CORS)响应头”webfont问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆