Pages - Menu

2023年7月28日 星期五

[GCP]gcs cors設定

睡睡念

架構從本來的 NFS全部轉到GCS上了,
所以cors也要跟著設定


正文

將下面檔案,存成json

[
    {
      "origin": ["https://tester.abc.com/"],
      "method": ["GET","PUT","POST","OPTIONS","DELETE","PATCH"],
      "responseHeader": ["Content-Type", "DNT","X-CustomHeader","X-LANG,Keep-Alive","User-Agent","X-Requested-With","If-Modified-Since,Cache-Control","X-Api-Key,X-Device-Id","Access-Control-Allow-Origin"],
      "maxAgeSeconds": 3600
    }
]

執行,收工。

gsutil cors set example_cors_file.json gs://example_bucket

感覺我好像再騙文章。

補充,origin不能用 * 的萬用符號,之前測了沒有效果 ,
未來會不會改不清楚。

查看bucket有沒有設定cors則用

gsutil cors get gs://example_bucket


如果要用gcloud/api,請看下面連結

ref. 設定和查看 CORS 組態

沒有留言:

張貼留言