Docs Ordnary Web Services Ordnary R2
CORS policy
Letting browsers on other origins read from or upload to a bucket: the rule fields and the usual setups.
A browser only lets a page call a different origin when that origin allows it. Without a CORS policy, a script on your site cannot fetch from the bucket's public domain or upload to it with a presigned URL. Plain <img> and <a> tags do not need CORS.
Rules
originslistRequired- The sites allowed, such as
https://app.example.com. Use*to allow every origin for public reads. methodslistRequired- GET and HEAD for reads; PUT, POST and DELETE for uploads from the browser.
headerslist- Request headers the browser may send, such as
Content-Typeorx-amz-*headers for uploads. exposeHeaderslist- Response headers scripts may read, such as
ETag. maxAgeSecondsnumber- How long the browser caches the preflight answer.
Typical setups
Scripts on any site may fetch objects from the public domain.
[
{ "origins": ["*"], "methods": ["GET", "HEAD"], "maxAgeSeconds": 86400 }
]Your app uploads straight from the browser with presigned URLs.
[
{
"origins": ["https://app.example.com"],
"methods": ["PUT", "GET", "HEAD"],
"headers": ["Content-Type"],
"exposeHeaders": ["ETag"],
"maxAgeSeconds": 3600
}
]