如何解决“缺少跨域资源共享(CORS)响应标头"的问题.webfont问题? [英] How can I fix the 'Missing Cross-Origin Resource Sharing (CORS) Response Header' webfont issue?
问题描述
由于某些原因,字体已停止在我的网站上呈现.字体存储在本地,与站点位于同一服务器上.
For some reason fonts have stopped rendering on my sites. The fonts are stored locally, on the same server as the site.
我查了一下问题,这似乎是一个缺少跨域资源共享(CORS)响应标头
,但我无法理解解决方案.
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.
所有说做的网站都使用: Access-Control-Allow-Origin:*
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?
我该如何解决该问题?
有问题的网站是: http://cyclistinsuranceaustralia.com.au/
例如,右上角的电话号码应为Bebas字体,但默认为Impact.
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:
起源' http://www.cyclistinsuranceaustralia.com.au 的字体已被Cross-Origin禁止加载资源共享政策:"Access-Control-Allow-Origin"标头具有值" http://www.cyclistinsuranceaustralia.com.au '不等于提供的原点.因此,不允许访问来源" http://cyclistinsuranceaustralia.com.au ".
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.
我联系主持人说:
Access-Control-Allow-Origin "http://www.cyclistinsuranceaustralia.com.au"
在我的.htaccess文件中,但这没有变化.
in my .htaccess file but this has no change.
推荐答案
在您的HTML中,您设置了基本"标签:
In your HTML you have set a "base" tag:
<base href="http://www.cyclistinsuranceaustralia.com.au/">
- 如果不需要,请从HTML中删除该行.从 http://cyclistinsuranceaustralia.com.au 观看时,这应该可以使字体工作.
- 您可能需要将 http://www.cyclistinsuranceaustralia.com.au 重定向到 http://cyclistinsuranceaustralia.com.au
- 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.
- You'll probably need to redirect http://www.cyclistinsuranceaustralia.com.au to http://cyclistinsuranceaustralia.com.au
这篇关于如何解决“缺少跨域资源共享(CORS)响应标头"的问题.webfont问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!