Skip to content

Instantly share code, notes, and snippets.

@developius
Last active July 23, 2021 04:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save developius/5bfd74401da82e149f23dfa8a09c7ff2 to your computer and use it in GitHub Desktop.
Save developius/5bfd74401da82e149f23dfa8a09c7ff2 to your computer and use it in GitHub Desktop.
Google Cloud Storage example CORS configuration for Rails/ActiveStorage

This gist shows you how to configure a Google Cloud Storage bucket CORS for use with Rails' ActiveStorage (or any other direct-upload mechanism).

  1. Update the policy JSON to reflect your setup (likely only changing the origin parameter)
  2. Run this: $ gsutil cors set ./cors-json-file.json gs://<bucket-name>
[
{
"origin": ["https://example.com"],
"responseHeader": [
"Content-Type",
"Content-Md5",
"Origin",
"Content-Disposition"
],
"method": [
"PUT",
"POST",
"GET",
"HEAD",
"DELETE",
"OPTIONS"
],
"maxAgeSeconds": 3600
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment