CORS Examples

This page provides common CORS configuration examples for use with Akave O3. Save these as cors.json and use them with the put-bucket-cors command via aws s3api.

Allow All Origins (Public Read)

{
  "CORSRules": [
    {
      "AllowedHeaders": ["*"],
      "AllowedMethods": ["GET"],
      "AllowedOrigins": ["*"],
      "MaxAgeSeconds": 3000
    }
  ]
}

Allow Specific Origin (e.g. frontend site)

{
  "CORSRules": [
    {
      "AllowedHeaders": ["Authorization"],
      "AllowedMethods": ["GET", "PUT"],
      "AllowedOrigins": ["https://frontend.example.com"],
      "ExposeHeaders": ["ETag"],
      "MaxAgeSeconds": 600
    }
  ]
}

Allow Web Uploads from Browser

{
  "CORSRules": [
    {
      "AllowedHeaders": ["*"],
      "AllowedMethods": ["POST", "PUT", "GET"],
      "AllowedOrigins": ["https://app.example.com"],
      "ExposeHeaders": ["ETag"],
      "MaxAgeSeconds": 3600
    }
  ]
}

How to Use with CLI

Save any of these examples to a file named cors.json, then run:

aws s3api put-bucket-cors \
  --bucket my-akave-bucket \
  --cors-configuration file://cors.json \
  --endpoint-url https://o3-rc1.akave.xyz

This will apply the configuration to your bucket.

Last updated on