Google Cloud Storage cors 政策允许所有

11 cors google-cloud-storage google-cloud-platform

我尝试使用以下命令允许所有来源:

gsutil cors set /tmp/cors.json gs://my_bucket
Run Code Online (Sandbox Code Playgroud)

正确的 json 文档是:

 [
    {
      "origin": ["*"]
    }
]
Run Code Online (Sandbox Code Playgroud)

或者:

[
    {
      "origin": "*"
    }
]
Run Code Online (Sandbox Code Playgroud)

小智 24

作为参考,

  1. 在 Cloud Console 中打开 Google Cloud Shell。
printf '[{"origin": ["*"],"responseHeader": ["*"],"method":
["GET","POST","HEAD"],"maxAgeSeconds": 86400}]' > cors.json

gsutil cors set cors.json gs://<bucket_name>
Run Code Online (Sandbox Code Playgroud)


sid*_*ker 7

它应该是"origin": ["*"]

origin即使您只想指定单个源或仅指定通配符,该值也应该是一个数组*例如,请参阅https://cloud.google.com/storage/docs/gsutil/commands/cors#description中的示例。