简体   繁体   English

Google字体:无访问权限-允许来源:*

[英]Google Font: no Access-Control-Allow-Origin:*

WordPress Website with the issue: *see below WordPress网站出现问题:*请参阅下文

Hello. 你好。 On my incognito Chrome browser and Firefox, Google Fonts aren't rendering. 在隐身的Chrome浏览器和Firefox上,未显示Google字体。

The error I get in the console is: 我在控制台中得到的错误是:

Font from origin 'http://fonts.gstatic.com' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://volusiaflaglerac.com' is therefore not allowed access.

Assuming from these instructions https://developers.google.com/fonts/docs/troubleshooting , a proxy is stripping out Access-Control-Allow-Origin:* 根据这些说明https://developers.google.com/fonts/docs/troubleshooting ,代理将剥离Access-Control-Allow-Origin:*

So I put this code in my .htaccess: 所以我把这段代码放在我的.htaccess文件中:

Header add Access-Control-Allow-Origin "*" Header add Access-Control-Allow-Methods: "GET,POST,OPTIONS,DELETE,PUT"

This is the code for one of the Google Fonts: 这是其中一种Google字体的代码:

<link href='http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz:400,700' rel='stylesheet' type='text/css'>

According to the report I run on here http://www.rexswain.com/httpview.html , it is reading the Access Control code. 根据我在http://www.rexswain.com/httpview.html上运行的报告,它正在读取访问控制代码。

I'm still seeing the default fonts. 我仍然看到默认字体。

What am I missing? 我想念什么?

Edit: please help! 编辑:请帮忙!

  • Edit: The issue has been resolved and I have removed the URL 编辑:问题已解决,我已删除网址

This is a security issue on your server preventing itself from downloading foreign files. 这是服务器上的安全问题,阻止其自身下载外部文件。

Since the .htaccess modification didn't work, you should download the google font and add it to your site. 由于.htaccess修改不起作用,因此您应该下载google字体并将其添加到您的网站。

FYI, this Chrome extension can help you bypass cross origin requests on your browser, but the error will still remain for your users 仅供参考,此Chrome扩展程序可以帮助您绕过浏览器上的跨源请求,但对于您的用户来说,错误仍然存​​在

https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?utm_source=chrome-ntp-icon https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?utm_source=chrome-ntp-icon

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM