Cors Not being passed through on R2 Bucket With Custom Domain?

What is the name of the domain?

https://r2test.simmercdn.com

What is the error message?

Access to fetch at ‘https://r2test.simmercdn.com/unity/ArOcg0jhIjQgaW2bkAbPZlOkgc83/staging/1744087423214/Build/2022.3.47f1-gzip-minimal.data.gz’ from origin ‘http://localhost:8086’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.

What is the issue you’re encountering

Cors Headers being passed through to custom domain.

What steps have you taken to resolve the issue?

curl -I not showing Access-Control-Allow-Origin *:

curl -I “Origin: http://localhost:8086https://r2test.simmercdn.com/unity/ArOcg0jhIjQgaW2bkAbPZlOkgc83/staging/1744087423214/Build/2022.3.47f1-gzip-minimal.data.gz
curl: (3) URL rejected: Malformed input to a URL function
HTTP/2 200
date: Tue, 08 Apr 2025 18:45:32 GMT
content-type: application/gzip
etag: W/“29dccbadd096c06cbbf4105c471ca0d3”
last-modified: Tue, 08 Apr 2025 04:43:43 GMT
vary: Accept-Encoding
cf-cache-status: HIT
age: 727
report-to: {“endpoints”:[{“url”:“https://a.nel.cloudflare.com/report/v4?s=%2BqaIDgyuzMcRYk72RK%2BerNrQ5edvfRasZhQVib54I3gGs9bvONQs2u%2BChzuDtm3ayfKAEk4wdsxsPihv6aum5PHyoPJtxwaDowePwRCVnnH%2FEhTzjl6pN%2FLge2DEwWrBwkBLJvqUEAl2t3Gr5Nnn7dq9Rw%3D%3D”}],“group”:“cf-nel”,“max_age”:604800}
nel: {“success_fraction”:0,“report_to”:“cf-nel”,“max_age”:604800}
server: cloudflare
cf-ray: 92d3ec1d5cfa5c1b-SJC
alt-svc: h3=“:443”; ma=86400
server-timing: cfL4;desc=“?proto=TCP&rtt=17877&min_rtt=13966&rtt_var=4801&sent=8&recv=11&lost=0&retrans=0&sent_bytes=2954&recv_bytes=653&delivery_rate=195418&cwnd=254&unsent_bytes=0&cid=30e7b33569063871&ts=57&x=0”

My bucket CORS settings:

[
{
“AllowedOrigins”: [
“*”
],
“AllowedMethods”: [
“GET”,
“POST”,
“PUT”,
“HEAD”,
“DELETE”
],
“AllowedHeaders”: [
“content-type”,
“content-encoding”
],
“ExposeHeaders”: [
“ETag”
],
“MaxAgeSeconds”: 3000
}
]

It seems like adding this to cors policy worked: “ExposeHeaders”: “Access-Control-Allow-Origin” worked.

My site is set up to upload games, and this didn’t work automatically, but it did work when I uploaded a new game. So maybe a purge cache or similar might fix.

Yay! Maybe this helps someone else.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.