google storage vedio files cannot plays directly from localhost angular

孤人 提交于 2019-12-24 18:25:12

问题


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



来源:https://stackoverflow.com/questions/57399120/google-storage-vedio-files-cannot-plays-directly-from-localhost-angular

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!