Skip to content

Commit b56251e

Browse files
authored
r2: improve cors docs re: custom domains (#27096)
* r2: improve cors docs re: custom domains * r2: fix w/ docs agent
1 parent bb58b9e commit b56251e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/content/docs/r2/buckets/cors.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ The following example allows browser-based uploads from `https://example.com` wi
6363
]
6464
```
6565

66+
## Use CORS with a custom domain
67+
68+
[Custom domains](/r2/buckets/public-buckets/#custom-domains) connected to an R2 bucket with a CORS policy automatically return CORS response headers for [cross-origin requests](https://fetch.spec.whatwg.org/#http-cors-protocol).
69+
70+
Cross-origin requests must include a valid `Origin` request header, for example, `Origin: https://example.com`. If you are testing directly or using a command-line tool such as `curl`, you will not see CORS `Access-Control-*` response headers unless the `Origin` request header is included in the request.
71+
72+
:::caution[Caching and CORS headers]
73+
74+
If you set a CORS policy on a bucket that is already serving traffic using a custom domain, any existing cached assets will not reflect the CORS response headers until they are refreshed in cache. Use [Cache Purge](/cache/how-to/purge-cache/) to purge the cache for that hostname after making any CORS policy related changes.
75+
76+
:::
77+
6678
## Add CORS policies from the dashboard
6779

6880
1. In the Cloudflare dashboard, go to the **R2 object storage** page.

0 commit comments

Comments
 (0)