CORS policies
Cross-origin resource sharing (CORS) defines how clients and servers across different domains share resources. You can manage your CORS policies to open services to requests from specific origins or any domain at all.
Managing CORS on Object Storage is essential. Your applications need access from particular domains, and CORS policies control what requests and responses each origin is permitted.
Currently, CORS policies are only supported on legacy (E0, E1) endpoints.
Prerequisite
You need a tool installed to manage your policies and the name of the bucket where you want to apply a policy. As a best practice, you can use s3cmd. Review Use s3cmd with Object Storage to get it installed and configured.
Once you've got that done, follow these steps:
-
Verify your connection by listing your buckets, for the endpoint (S3 hostname) you configured in s3cmd:
s3cmd ls -
From the response, store the name of the bucket, where you want to apply the CORS policy:
2026-09-24 16:13 s3://example-cors-bucketIn this example, a single bucket was returned, named
example-cors-bucket, which is what we'll use throughout this process. -
Get the full URL for the bucket.
Review your CORS policies
Use the info flag to view current policies for your bucket:
s3cmd info s3://example-cors-bucketThe response should look similar to this:
s3://example-cors-bucket/ (bucket):
Location: default
Payer: BucketOwner
Expiration Rule: none
Policy: none
CORS: <CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><CORSRule>...
ACL: 31ffbc26-d6ed-4bc3-8a14-ad78fe8f95b6: FULL_CONTROL
In this example, the target bucket was set up with CORS Enabled in āAkamaiā Cloud Manager. So, it already has a basic policy, that's permissive across all methods and origins.
Deploy CORS policies
Cloud Manager gives you a generic policy. For more fine-grained control, you can set up a custom policy in XML format:
<!-- File: cors_policies.xml -->
<CORSConfiguration>
<CORSRule>
<AllowedHeader>*</AllowedHeader>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<AllowedOrigin>*</AllowedOrigin>
<ExposeHeader>*</ExposeHeader>
<MaxAgeSeconds>3000</MaxAgeSeconds>
</CORSRule>
</CORSConfiguration>This includes these fields:
<CORSConfiguration>. Use this to wrap one or more<CORSRule>elements.<AllowedHeader>. Use this to specify permitted request headers. See AWS's Common Request Headers documentation for a list of commonly used request headers.<AllowedMethod>. Include one or more instances of this field to specify each permitted HTTP methodāGET, PUT, POST, DELETE, or HEAD.<AllowedOrigin>. Use this to specify which domains can make cross-origin requests.<ExposeHeader>. Optionally, use this to specify which response headers may be exposed. See AWS's Common Response Headers documentation for a list of commonly used response headers.<MaxAgeSeconds>. Optionally, include this to set how long browsers can cache preflight responses. You can include one instance of this per rule.
Example CORS policies
Here are some example XML files for CORS policies.
-
Public read-only access. This lets any origin, with any request headers, make GET and HEAD requests to the bucket.
<CORSConfiguration> <CORSRule> <AllowedHeader>*</AllowedHeader> <AllowedMethod>GET</AllowedMethod> <AllowedMethod>HEAD</AllowedMethod> <AllowedOrigin>*</AllowedOrigin> </CORSRule> </CORSConfiguration> -
Fine-grained control for
example.com. This control requests fromexample.com. The<AllowedOrigin>elements specify the range of possibleexample.comdomains. The two policies distinguish the kinds of headers allowed, based on the kinds of request methods.<CORSConfiguration> <CORSRule> <AllowedHeader>Authorization</AllowedHeader> <AllowedMethod>GET</AllowedMethod> <AllowedMethod>HEAD</AllowedMethod> <AllowedOrigin>http://example.com</AllowedOrigin> <AllowedOrigin>http://*.example.com</AllowedOrigin> <AllowedOrigin>https://example.com</AllowedOrigin> <AllowedOrigin>https://*.example.com</AllowedOrigin> <ExposeHeader>Access-Control-Allow-Origin</ExposeHeader> <MaxAgeSeconds>3000</MaxAgeSeconds> </CORSRule> <CORSRule> <AllowedHeader>Authorization</AllowedHeader> <AllowedHeader>Origin</AllowedHeader> <AllowedHeader>Content-*</AllowedHeader> <AllowedMethod>PUT</AllowedMethod> <AllowedMethod>POST</AllowedMethod> <AllowedMethod>DELETE</AllowedMethod> <AllowedOrigin>http://example.com</AllowedOrigin> <AllowedOrigin>http://*.example.com</AllowedOrigin> <AllowedOrigin>https://example.com</AllowedOrigin> <AllowedOrigin>https://*.example.com</AllowedOrigin> <ExposeHeader>ETag</ExposeHeader> <MaxAgeSeconds>3000</MaxAgeSeconds> </CORSRule> </CORSConfiguration>
Deploy your policy
-
Save your policy to an XML file, for example
cors_policies.xml. -
Deploy with
s3cmd setcors, to your target bucket (example-cors-bucket):s3cmd setcors cors_policies.xml s3://example-cors-bucket -
Verify the deployment:
s3cmd info s3://example-cors-bucket
The response should look similar to this:
s3://example-cors-bucket/ (bucket):
Location: default
Payer: BucketOwner
Expiration Rule: none
Policy: none
CORS: <CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><CORSRule><AllowedMethod>GET</AllowedMethod><AllowedMethod>HEAD</AllowedMethod><AllowedOrigin>http://*.example.com</AllowedOrigin><AllowedOrigin>http://example.com</AllowedOrigin><AllowedOrigin>https://*.example.com</AllowedOrigin><AllowedOrigin>https://example.com</AllowedOrigin><AllowedHeader>Authorization</AllowedHeader><MaxAgeSeconds>3000</MaxAgeSeconds><ExposeHeader>Access-Control-Allow-Origin</ExposeHeader></CORSRule><CORSRule><AllowedMethod>PUT</AllowedMethod><AllowedMethod>DELETE</AllowedMethod><AllowedMethod>POST</AllowedMethod><AllowedOrigin>http://*.example.com</AllowedOrigin><AllowedOrigin>http://example.com</AllowedOrigin><AllowedOrigin>https://*.example.com</AllowedOrigin><AllowedOrigin>https://example.com</AllowedOrigin><AllowedHeader>Authorization</AllowedHeader><AllowedHeader>Content-*</AllowedHeader><AllowedHeader>Origin</AllowedHeader><MaxAgeSeconds>3000</MaxAgeSeconds><ExposeHeader>ETag</ExposeHeader></CORSRule></CORSConfiguration>
ACL: 31ffbc26-d6ed-4bc3-8a14-ad78fe8f95b6: FULL_CONTROLTroubleshoot common CORS errors
-
Review active policies on your target bucket (
example-cors-bucket):s3cmd info s3://example-cors-bucket -
Examine request/response data by using a signed URL and
cURL. This can give you insights on any possible inconsistencies between existing CORS policies and the actual requests and responses.s3cmd signurl s3://example-cors-bucket/example.txt +300 -
Send a verbose request, that includes the full URL to the bucket:
curl -v "https://example-cors-bucket.us-southeast-1.linodeobjects.com/index.md?AWSAccessKeyId=...&Expires=...&Signature=..."The
-vflag provides detailed output to help identify mismatches. -
Compare the cURL output against the bucket's active CORS policy.
Updated about 3 hours ago
