Skip to content

Instantly share code, notes, and snippets.

@pjbelo
Last active August 19, 2022 11:32
Show Gist options
  • Save pjbelo/a38da9a69b4b6cefc3b1434a5cb8c7f4 to your computer and use it in GitHub Desktop.
Save pjbelo/a38da9a69b4b6cefc3b1434a5cb8c7f4 to your computer and use it in GitHub Desktop.
Google Cloud Storage CORS configuration

Use the gsutil cors command to configure CORS on a bucket:

gsutil cors set cors-json-file.json gs://example

Where cors-json-file.json contains:

[
    {
      "origin": ["*"],
      "responseHeader": ["*"],
      "method": ["GET", "POST", "PUT", "OPTIONS", "HEAD", "DELETE"],
      "maxAgeSeconds": 3600
    }
]

This is a DANGEROUS wildcard configuration. Use it only to test, then set your parameters correctly.

You can also use the gsutil cors command to get the CORS configuration of a bucket:

gsutil cors get gs://example

More info: https://cloud.google.com/storage/docs/configuring-cors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment