🎉Black Friday deal: 40% off all lifetime licenses with code BF2026
Policy & Security

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.

Storage Provider

Comma-separated domains or * for public access.

Allowed HTTP Methods
CORS Configuration JSON
[
  {
    "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.

Frequently asked questions

Check that the origin matches exactly, including the scheme and port, that the method (PUT, POST, GET) is allowed, and that every request header your client sends, such as Content-Type, is listed in AllowedHeaders. Browsers cache preflight responses, so test in a fresh tab after changes.
Yes. R2 supports bucket CORS policies with the same AllowedOrigins, AllowedMethods, AllowedHeaders, ExposeHeaders, and MaxAgeSeconds fields as S3. You can set them in the dashboard or with Wrangler.
Expose ETag. The browser needs to read the ETag of each uploaded part to complete a multipart upload.

Need a faster way to browse & share S3 objects?