google maps-跨域请求被阻止:同源策略禁止在以下位置读取远程资源 [英] google maps - Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at

查看:264
本文介绍了google maps-跨域请求被阻止:同源策略禁止在以下位置读取远程资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用google maps api,在页面上我有这个

I am using google maps api and on the page I have this

<link type="text/css" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">

现在,正因为如此,如您在此链接中所见

now, because of this, as you can see in this link

https://fonts.googleapis.com/css?family= Roboto:300,400,500 有字体文件-包含在url中,AFA我知道这会引起问题。在萤火虫中,它显示

https://fonts.googleapis.com/css?family=Roboto:300,400,500 there are font files - included by url, and AFA i understand it causes the problem. In firebug it shows


跨域请求被阻止:同源策略禁止读取
远程资源
https://themes.googleusercontent.com/static/fonts/roboto/v11 /2UX7WLTfW3W8TclTUvlFyQ.woff
可以通过将资源移至同一域或启用CORS来解决此问题。

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://themes.googleusercontent.com/static/fonts/roboto/v11/2UX7WLTfW3W8TclTUvlFyQ.woff This can be fixed by moving the resource to the same domain or enabling CORS.

即使试图将其添加到我的htaccess中,也无法正常工作,它仍然在萤火虫中显示错误

Even trying to add this in my htaccess, does not work, it still shows the error in firebug

Header set Access-Control-Allow-Origin: *

apache的标题模块已启用,我设置了其他标题并且可以。我正在使用xampp 1.7.4。
我也不想将css文件和/或字体移动到我的本地文件中,因为Google将来可能会进行更改。

apache's headers mod is enabled, I have other headers set and it is ok. Im using xampp 1.7.4. I also do not want to move the css file and/or the fonts into my local files, because of possible changes in the future by google.

qsn1::如何处理此错误。

qsn2:为什么只显示那些字体文件错误?因为例如我也包括了Google Maps api的脚本,并且没有问题。

qsn2: why it shows error only with those font files ? Because e.g. I have google maps api's script included as well, and there is no problem with that.

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places"></script>

谢谢

推荐答案

您是否使用任何嗅探器工具?使用Fiddler2检查网络通信时出现此错误。如果不运行该工具,请尝试使用它。

Are you using any sniffer tool? I am getting this error when I use Fiddler2 to check network communication. Try without the tool if you running it.

这篇关于google maps-跨域请求被阻止:同源策略禁止在以下位置读取远程资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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