google storage origin ‘https://xxx.com’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
1. 激活 cloud shell
![image.png](https://img-blog.csdnimg.cn/img_convert/20c0ef1aff9cac1deee953512f4bd476.png)
2. 在 cloud shell 中设置 cors config
查看cors设置
gcloud storage buckets describe gs://bucket-name --format="default(cors)"
设置 cors
gcloud storage buckets update gs://bucket-name --cors-file=cors.config
这里可以 vi 创建一个 cors.config,放入下面的 json👇
[
{
"origin": [
"*"
],
"responseHeader": ["*","Origin", "Accept", "X-Requested-With", "Authorization", "Content-Type", "Content-Length", "Accept-Encoding", "X-CSRF-Token"],
"method": [
"*",
"GET",
"OPTIONS"
],
"maxAgeSeconds": 1
}
]
设置完成后,可能无法立即生效,稍微等一会儿。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)