S3 & R2 CORS Policy Generator
Fix Access-Control-Allow-Origin issues instantly. Generate validated CORS JSON and XML configuration rules tailored for AWS S3, Cloudflare R2, MinIO, and S3-compatible storage providers.
Configure CORS Rules
Select your target cloud provider and access preferences.
Comma-separated domains or * for public access.
[
{
"AllowedOrigins": [
"*"
],
"AllowedMethods": [
"GET",
"PUT",
"POST",
"DELETE",
"HEAD"
],
"AllowedHeaders": [
"*"
],
"ExposeHeaders": [
"ETag",
"x-amz-request-id",
"x-amz-id-2"
],
"MaxAgeSeconds": 3600
}
]What a CORS policy does on S3 and R2
Browsers block JavaScript from reading responses from another origin unless the server allows it. When a web app uploads to or downloads from a bucket directly, the bucket must return Access-Control-Allow-Origin and related headers. A CORS policy on the bucket tells S3 or R2 which origins, methods, and headers to allow.
Without a policy, direct browser uploads with presigned URLs fail with a CORS error, even when the presigned URL itself is valid.
JSON vs XML format
The AWS S3 console and the AWS CLI accept CORS rules as JSON. The S3 REST API uses XML. Cloudflare R2 accepts JSON in the dashboard and through Wrangler, and MinIO accepts the S3 XML format. This generator outputs both so you can paste the right one for your provider.
How to apply the policy
AWS CLI: save the JSON as cors.json and run aws s3api put-bucket-cors --bucket my-bucket --cors-configuration file://cors.json.
Cloudflare R2: open the bucket settings, find CORS Policy, and paste the JSON rules. With Wrangler, run wrangler r2 bucket cors set my-bucket --file cors.json.
MinIO: use mc cors set or the S3 API with the XML output.
Keep the policy tight
List exact origins such as https://app.example.com instead of *, allow only the methods your app uses, and expose only headers the client must read, such as ETag for multipart uploads. A wildcard origin is fine for public read-only assets, but avoid it for upload endpoints.