Created
April 26, 2019 12:52
-
-
Save jobsamuel/b4022d6937dad50d2d9195e62f1bcb4d to your computer and use it in GitHub Desktop.
How to set up CORS in your Google Cloud Storage Bucket
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Go to "Activate Google Cloud Shell" in https://console.cloud.google.com/home. | |
echo '[{"origin": ["*"],"responseHeader": ["Content-Type"],"method": ["GET", "HEAD"],"maxAgeSeconds": 3600}]' > cors-config.json | |
# If you want to restrict the access one or more specific domains, add their URL to the array: | |
echo '[{"origin": ["https://yourdomain.com"],"responseHeader": ["Content-Type"],"method": ["GET", "HEAD"],"maxAgeSeconds": 3600}]' > cors-config.json | |
# Set CORS config. | |
gsutil cors set cors-config.json gs://YOUR_BUCKET_NAME | |
# Verify if everything is OK. | |
gsutil cors get gs://YOUR_BUCKET_NAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment