How to access R2 buckets with jurisdiction from CF Pages?

Hi, I'm using Cloudflare Pages and R2 Buckets with Jurisdiction EU. I can access the buckets from Workers (when adding the jurisdiction to the binding in the toml file), but that does not work for the pages project as those bindings can only be configured via the UI / dashboard. There, the buckets don't appear. Any idea what to do? Thanks in advance.
12 Replies
Walshy
Walshy10mo ago
When you make a bucket you can define a jurisdiction. Then you should be able to just bind it and use it as normal within Pages
Hannes
HannesOP10mo ago
Yes, I did specify the jurisdiction when creating the bucket. However, I cannot add it in the UI. Those buckets don't appear, instead I only get this:
Hannes
HannesOP10mo ago
No description
Hannes
HannesOP10mo ago
Get Started links to the R2 Overview Page where I can see all the buckets.
Hannes
HannesOP10mo ago
When creating a Bucket without jurisdiction, I can add the binding...
No description
Hannes
HannesOP10mo ago
But not for Buckets with jurisdiction.
Walshy
Walshy10mo ago
I see, ok so the jurisdiction seems required by the binding - https://developers.cloudflare.com/r2/reference/data-location/#using-jurisdictions-from-workers and seems like the UI needs an update too to show these I'll cut a ticket but likely won't be able to get to this super quickly for my own ref: WC-2034
Hannes
HannesOP10mo ago
Ok, thanks! Is there any workaround? As far as I know I can't change the jurisdiction of existing buckets and using the cli / toml only works for workers, not for pages. Right?
Hannes
HannesOP10mo ago
I tried using the API and noticed some very strange things. I used the following request: PATCH https://api.cloudflare.com/client/v4/accounts/MY_ACCOUNT_ID/pages/projects/MY_PROJECT Auth Header + Content Type application/json body:
{
"deployment_configs": {
"production": {
"r2_buckets": {
"MY_BUCKET": {
"name": "bucket-with-jurisdiction"
}
}
}
}
}
{
"deployment_configs": {
"production": {
"r2_buckets": {
"MY_BUCKET": {
"name": "bucket-with-jurisdiction"
}
}
}
}
}
What happens is the following: - the API does not do any validation whatsoever. I can use "name": "non-existing-bucket" and that bucket appears in the UI (see in the screenshot). - Buckets with Jurisdiction also appear there, but they cannot be clicked on (the URL which the link redirects to ends with /r2/default/buckets/[bucketname] instead of /r2/eu/buckets/[bucketname] - adding a "jurisdiction" key to the json body of the api request does not change anything.
No description
Hannes
HannesOP10mo ago
And - is there anywhere I can track the progress of this ticket? Thanks in advance!
Walshy
Walshy10mo ago
yeah this is expected, the pages system is different from where the normal bindings live (workers service). The validation therefore is on upload It's an internal ticket so no sorry
Hannes
HannesOP9mo ago
OK, thanks anyway! I guess I monitor the changelog. Just noticed another bug there (this time with workers, where it works with the .toml file): The UI ist still broken for that and when I try to add secrets, I get "bucket not found". Seems like when I press "Deploy" in the Environment Variables section, it also tries to update r2 bucket bindings? That's quite a bummer...
Want results from more Discord servers?
Add your server