CORS

This document provides instructions to manage CORS using the CLI. Additionally, these tasks can also be performed using the web console and API.

Prerequisites:

Commands

Get the CORS configuration for the bucket my-bucket:

aws s3api get-bucket-cors --bucket my-bucket --endpoint-url https://s3-eu-central-2.ionoscloud.com

Set up CORS configuration for the bucket my-bucket:

aws s3api put-bucket-cors --bucket my-bucket --cors-configuration file://cors.json --endpoint-url https://s3-eu-central-2.ionoscloud.com

Sample CORS request

{
 "CORSRules": [
 {
 "AllowedOrigins": ["http://www.example.com"],
 "AllowedHeaders": ["*"],
 "AllowedMethods": ["PUT", "POST", "DELETE"],
 "MaxAgeSeconds": 3000,
 "ExposeHeaders": ["x-amz-server-side-encryption"]
 },
 {
 "AllowedOrigins": ["*"],
 "AllowedHeaders": ["Authorization"],
 "AllowedMethods": ["GET"],
 "MaxAgeSeconds": 3000
 }
 ]
}

For more information, see put-bucket-cors command reference.

Last updated