S3 CORS Policy Generator: Create AWS Bucket CORS JSON for Browser Uploads
Generate AWS S3 CORS policies for browser uploads, public reads, signed downloads, and presigned URLs. Learn CORSRules, AllowedOrigins, AllowedMethods, AllowedHeaders, ExposeHeaders, MaxAgeSeconds, and put-bucket-cors.
Build an S3 CORS policy for frontend uploads and reads
Use Spoold's S3/R2 CORS Generator to create an AWS S3 bucket CORS policy for browser uploads, public reads, signed downloads, and presigned URL flows. The tool produces editable policy JSON, an AWS CLI file with CORSRules, and a preflight curl for testing.
What is an S3 CORS policy?
An S3 CORS policy is a bucket-level rule set that tells Amazon S3 which browser origins can access objects, which HTTP methods are allowed, which request headers can be sent, and which response headers JavaScript can read. It is separate from IAM, bucket policies, ACLs, and presigned URL authorization.
S3 console JSON vs AWS CLI JSON
The S3 console commonly shows the rules themselves. The AWS CLI put-bucket-cors command expects a wrapper object with CORSRules. This small difference is easy to miss, so the generator outputs both.
Rule list
[
{
"AllowedOrigins": ["https://app.example.com"],
"AllowedMethods": ["GET", "PUT", "HEAD"],
"AllowedHeaders": ["Content-Type"],
"ExposeHeaders": ["ETag"],
"MaxAgeSeconds": 3600
}
]AWS CLI file
{
"CORSRules": [
{
"AllowedOrigins": ["https://app.example.com"],
"AllowedMethods": ["GET", "PUT", "HEAD"],
"AllowedHeaders": ["Content-Type"],
"ExposeHeaders": ["ETag"],
"MaxAgeSeconds": 3600
}
]
}Recommended S3 CORS policies by use case
| Use case | Methods | Headers | Expose |
|---|---|---|---|
| Public asset read | GET, HEAD | Usually empty | Content-Length |
| Presigned PUT upload | PUT, HEAD | Content-Type, x-amz-* | ETag |
| Presigned POST upload | POST, HEAD | Content-Type, x-amz-* | ETag |
| Signed download | GET, HEAD | Authorization if sent | ETag |
How to generate an S3 CORS policy
- Open the S3 CORS policy generator and select AWS S3.
- Pick a preset for public read, presigned upload, signed download, or assets.
- Add exact origins such as
https://app.example.comandhttp://localhost:3000. - Add all request headers your frontend sends.
- Copy the policy or download the AWS CLI JSON file.
- Apply it with
aws s3api put-bucket-cors --bucket BUCKET --cors-configuration file://cors-aws-cli.json.
Common S3 CORS mistakes
- Using the wrong wrapper: AWS CLI expects
CORSRules, not only a bare array. - Forgetting localhost: your production origin does not cover local dev.
- Allowing GET but uploading with PUT: the preflight method must be allowed.
- Missing upload headers: every header in
Access-Control-Request-Headersmust be covered. - Not exposing ETag: uploads may succeed, but JavaScript cannot read
ETagunless it is inExposeHeaders.
Use the debugger for failed preflight requests
Paste your current S3 CORS policy into the S3/R2 CORS debugger, then enter the browser origin, method, request headers, and console error. The debugger shows whether the request fails because of origin, method, request headers, exposed response headers, or wildcard origin with credentials.
Related Tools
Related Articles
CSV Operations Query Tool Online: Filter, Dedupe, Compare CSV and Excel
Use Spoold's free CSV Operations tool to query CSV, TSV, and Excel .xlsx files online. Filter rows, select columns, find unique values and duplicates, dedupe CSV data, compare columns, count by category, sort rows, and run numeric summaries in your browser.
Cloudflare R2 CORS Generator: Create Bucket CORS JSON for Browser Apps
Generate Cloudflare R2 CORS JSON for public reads, browser uploads, signed downloads, and presigned URL workflows. Learn AllowedOrigins, AllowedMethods, AllowedHeaders, ExposeHeaders, MaxAgeSeconds, and Wrangler-ready config.
R2 Presigned URL CORS: Fix Browser Upload and Download Errors
Cloudflare R2 presigned URLs still need bucket CORS when used from a browser. Learn how to allow PUT, POST, GET, Content-Type, x-amz-* headers, ETag exposure, localhost origins, and preflight requests.
Try It Now
Put this guide into practice with our free tools. No sign-up required.
Generate S3 CORS Policy