2

I have created a Compute Engine - VM and have several websites installed. Also, I have created Network services - Load balancing - Backend configuration: Created Backend services and join the instance group with the same VM above. - Created Cloud CDN and config SSL certificate also done.

The website is https://united-athle.hk/ The CDN domain is https://cdn.ua.sugarproject.com

When I visit the website, the following CORS issue occurred Access to resource at 'https://cdn.ua.sugarproject.com/wp-content/plugins/onesignal-free-web-push-notifications/sdk_files/manifest.json.php?gcm_sender_id=' from origin 'https://united-athle.hk' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I have read Cross-origin resource sharing (CORS), https://cloud.google.com/storage/docs/cross-origin but not really sure how-to config. My storage is in VM engine.

Does anyone have an idea?

INDRAJITH EKANAYAKE
  • 3,894
  • 11
  • 41
  • 63
Peter Ho
  • 23
  • 1
  • 3

1 Answers1

6

One option is to configure the web server software running on your VM to include an Access-Control-Allow-Origin header in its responses. For example, including an Access-Control-Allow-Origin: https://united-athle.hk header would allow cross-origin requests from https://united-athle.hk/. https://enable-cors.org/server.html has information on how to do this for a variety of web server software.

Alternatively, you could serve both portions of your website from a single domain name, eliminating the need for cross-origin requests.

jub0bs
  • 60,866
  • 25
  • 183
  • 186
elving
  • 1,441
  • 8
  • 7
  • Hi elving, Access-Control-Allow-Origin: setting doesn't work. It seem Google Cloud CDN rewrite the header. – Peter Ho May 15 '19 at 04:06
  • 2
    Google Cloud CDN never rewrites Access-Control-Allow-Origin headers. Perhaps you are getting cache hits from a cache entry that was inserted into cache before you configured your web server software to add the Access-Control-Allow-Origin header? If so, you can invalidate your cache. – elving May 15 '19 at 21:58
  • Hi elving, You are correct. the solution here https://enable-cors.org/server.html works for me now. It seem some caching issue previously. Now everything is fine. Thank you for your kindly help. – Peter Ho May 18 '19 at 04:46