问题描述
已被CORS政策阻止:所请求的资源上没有 Access-Control-Allow-Origin标头。因此,不允许访问来源''。
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.
尝试从Google存储空间加载wave文件时显示此消息。
this message when trying to load wave file from google storage.
我尝试了以下步骤,但不起作用,
使用gsutil在桶中配置CORS的cors命令:
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
推荐答案
如果您使用的是Chrome,我想提到Chrome不支持CORS请求的本地主机(自2010年以来打开的错误)[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
要解决此问题,您可以使用类似lvh.me的域(就像localhost一样指向127.0.0.1)或使用--disable-web-security启动chrome标记(假设您是ju
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).
也可以检查如何在此文档的Origin上使用通配符[2]
Also you can check how you can use wildcards on Origin on this document[2]
[1]
[2]
这篇关于谷歌存储视频文件不能直接从本地主机角度播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!