2

Background

  • I am running Google App Engine with Python using Flask.
  • I am calling certain web assets in Google Cloud Storage buckets via https://storage.googleapis.com/*

I can verify the Access-Control-Allow-Originheader is being set on the request, as per the evidence below.

enter image description here

Problem

How is it then that I still get the following error in my browser (chrome).

Font from origin 'https://storage.googleapis.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://localhost:8080' is therefore not allowed access.

Code

I am using the Flask Snippet "Decorator for the HTTP Access Control", to set origins as below:

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

-------- Edit-----------

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
Vinay Joseph
  • 5,515
  • 10
  • 54
  • 94

1 Answers1

0

This is a Community Wiki post of the last answer provided by Greg.

The CORS Access-Control-Allow-Origin header should be returned by the host server that is accepting the request, as it is the server that sets the rules for who can access its own resources.

The CORS OPTIONS preflight headers are to be set by the requester who is making the request, so that it properly identifies itself to the host server.

For more information, you can see this additional Stack Overflow post.

Community
  • 1
  • 1
Jordan
  • 693
  • 3
  • 16