来自origin' https://storage.googleapis.com'已被跨源资源共享策略阻止加载

时间:2015-09-26 04:09:50

标签: python google-chrome google-app-engine flask cors

背景

  • 我使用Flask运行使用Python的Google App Engine。
  • 我通过https://storage.googleapis.com/ *
  • 在Google云端存储分区中调用某些网络资源

我可以根据以下证据验证请求中是否设置了Access-Control-Allow-Origin标头。

enter image description here

问题

然后我的浏览器(chrome)仍然出现以下错误。

  

来自原点的字体' https://storage.googleapis.com'已被封锁   从跨源资源共享政策加载:否   '访问控制允许来源'标题出现在请求的上   资源。起源' http://localhost:8080'因此是不允许的   访问。

代码

我正在使用Flask Snippet"装饰器进行HTTP访问控制",将起点设置如下:

@admin_articles_routes.route('/xxx/xxx/xxx-xx')
@crossdomain(origin="*")
@authenticate_admin
def edit_article():

--------编辑-----------

Curl response
Vinays-MacBook-Pro:App-Engine vinay$ curl -version http://localhost:8080/xxxx/xxxx/xxxx-xxxx?ID=ahlkZXZ-Y2ZjLW1lbGJvdXJuZS13ZWJzaXRlcjbGUYgICAgICAgAoM
*   Trying ::1...
* connect to ::1 port 8080 failed: Connection refused
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /xxx/xxxx/xxxx-xxxxx?ID=ahlkZXZ-Y2ZjLW1lbGJvdXJuZS13ZWJzaXRlcjELEgdBcnRpY2xlIhBBcnRpY2xlR3JhZHBhS2V5DAsSB0FydGljbGUYgICAgICAgAoM HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.43.0
> Accept: */*
> Referer: rsion
> 
< HTTP/1.1 302 Found
< access-control-max-age: 21600
< location: http://localhost:8080/_ah/login?continue=http%3A//localhost%3A8080/xxxx/xxxxx/xxxx-xxxxx%3FID%3DahlkZXZ-Y2ZjLW1lbGJvdXJuZS13ZWJzbGUYgICAgICAgAoM
< access-control-allow-origin: *
< access-control-allow-methods: HEAD, GET
< content-type: text/html; charset=utf-8
< Cache-Control: no-cache
< Expires: Fri, 01 Jan 1990 00:00:00 GMT
< Content-Length: 575
< Server: Development/2.0

1 个答案:

答案 0 :(得分:1)

这是Greg提供的最后一个答案的Community Wiki post

CORS Access-Control-Allow-Origin标头应由接受请求的主机服务器返回,因为它是为谁设置访问其自身资源的规则的服务器。

CORS OPTIONS preflight headers将由发出请求的请求者设置,以便它正确地向主机服务器标识自己。

有关详细信息,您可以看到此附加Stack Overflow post

相关问题