google storage vedio files cannot plays directly f

2019-08-17 02:46发布

问题:

has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.

this message when trying to load wave file from google storage.

i tried these steps but it doesn't work, Use the gsutil cors command to configure CORS on a bucket: https://cloud.google.com/storage/docs/configuring-cors

回答1:

If you are using Chrome, I want to mention that Chrome does not support localhost for CORS requests (an error opened since 2010) [1], if you inspect the thread of this error, you will find the last comment made this year, therefore, this error is still in process for be resolved

To get around this you can use a domain like lvh.me (which points at 127.0.0.1 just like localhost) or start chrome with the --disable-web-security flag (assuming you're just testing).

Also you can check how you can use wildcards on Origin on this document[2]

[1] https://bugs.chromium.org/p/chromium/issues/detail?id=67743

[2] https://cloud.google.com/storage/docs/xml-api/put-bucket-cors