CORS (cross-origin resource sharing) decides which websites may call your storage bucket from a visitor's browser, for example a page that shows images from your bucket or lets visitors upload files straight to it. You can set it yourself from your storage page.
Set up CORS
- Go to Services and open your storage bucket.
- Find the CORS section.
- In Allowed websites (origins), enter each website that needs access, one per line, for example
https://www.example.com. You can add up to 10. - Under Browsers may, choose Download (GET, HEAD), Upload (PUT, POST) or Download and upload.
- Click Turn on CORS. To change the rules later, edit them and click Update CORS rules. To turn CORS off, click Remove CORS.
Rules for website addresses
- Use the full address with
https://, likehttps://www.example.comorhttps://app.example.com:8443. - For testing on your own computer you can use
http://localhost:3000(any port). - No
*wildcards and no paths.https://example.comandhttps://www.example.comare different websites, so add both if you use both.
Optional settings
- Exposed headers: response headers your page can read. Keep
ETagif you upload large files in parts. - Max age: how long browsers remember the check, in seconds. The default is 3600 (one hour), up to 86400.
Keep your bucket safe
- CORS does not give anyone access. Every request to your bucket still needs your access key or a signed link.
- Never put your secret key in website JavaScript. Anyone can read it from the page. For uploads from a browser, have your server create short-lived pre-signed URLs and let the browser upload with those.
- Only list the websites you actually use.
CORS can be changed while your storage service is active. If something does not work as expected, open a support ticket and include your bucket name and the website address.