CORS Configuration for Buckets

A CORS (Cross-Origin Resource Sharing) configuration can be applied to Hedvig S3 buckets to allow access to client web applications from outside a domain.

CORS configurations can be used in scenarios such as running a static website on Hedvig S3 and allowing JavaScript from web pages to communicate with S3 buckets using certain operations such as GET, PUT, and DELETE.

CORS Configuration Example

This example shows a JSON file named hedvigcors.json for s3cli to enable CORS and set related CORS rules on a bucket.

This configuration allows requests from all domains to send GET requests and allows all headers.

In addition, it also allows POST, PUT, DELETE, with a max age seconds of 3000, from the origin of:

http://bucket-website1.nginxvm.hedviginc.com:16000
{ "CORSRules": [ { "AllowedOrigins": [ "http://bucket-website1.nginxvm.hedviginc.com:16000"], "AllowedHeaders": ["*"], "AllowedMethods": ["POST", "PUT", "DELETE"], "MaxAgeSeconds": 3000 }, { "AllowedOrigins": ["*"], "AllowedMethods": ["GET"], "AllowedHeaders": ["*"] } ]
}

Use the AWS S3 CLI to apply the CORS rules to a bucket:

aws s3api put-bucket-cors --endpoint http://<hostname>:<port_number> --bucket <bucket_name> --cors-configuration

Loading...