Google Cloud Storage GCS - CORS Wildcard

Viewed 2108

In GCS is it possible to provide Wild card permission for all subdomain under a domain. Have referred documentation but it was not provided. GCS CORS Docs

3 Answers

First you need a cors configuration file that will be applied to your bucket, you can create a wildcard one like this:

echo '[{"origin": ["*"], "responseHeader": ["Content-Type"], "method": ["GET", "HEAD"], "maxAgeSeconds": 3600}]' > cors-config.json

Then apply this new config file to your bucket:

gsutil cors set cors-config.json gs://YOUR_BUCKET_NAME

You can check that it has been applied by running the:

gsutil cors get gs://YOUR_BUCKET_NAME

command and verifying that the response matched your config file.

(Sources: 1, 2)

Related