Actions17
- Bucket Actions
- Object Actions
- Batch Operations Actions
Bucket → Set CORS
AI-generatedSummary
Set CORS configuration for an R2 bucket
Inputs
- bucketName (required) — Name of the R2 bucket to apply the CORS configuration to.
- corsRules — Array of CORS rule objects, each defining allowedOrigins, allowedMethods, allowedHeaders, and maxAge.
Output shape
object with success (boolean) and message (string) indicating the result of the operation
On success the CORS configuration is stored; failures are raised as node operation errors.
Examples
Example 1: Configure a bucket to allow GET and POST from example.com and set max age to 6000 seconds
bucketName=my-bucket; corsRules=[{allowedOrigins=https://example.com, *, allowedMethods=[GET,POST], allowedHeaders=Content-Type, Authorization, maxAge=6000}]
Example 2: Set a permissive CORS policy for a public bucket
bucketName=public-data; corsRules=[{allowedOrigins=*, ; allowedMethods=[GET,POST,PUT,DELETE,HEAD]; allowedHeaders=; maxAge=3600}]
Example 3: Delete the existing CORS configuration
bucketName=my-bucket; corsRules=[]