R2 bucket with custom domain / no public access

I just connected a custom domain to a R2 bucket and made sure there is no cname flattening on the DNS entries.

It seems like public access to the bucket should be enabled automatically through the domain but it is not the case here.

Anyone have any insight on how I can access bucket contents publicly through a custom domain with https link?

If you are hitting the

Error 404

This object could not be viewed

You are not authorized to view this object

Page, don’t confuse that with not having Public Access, it’s just saying it can’t find the file.
Using your R2 Custom Domain is simple, just use the same file names that are in your bucket. For example, if you have a file called index.html, you can reach it using yourcustomdomain.example/index.html.
A common mistake is prefixing paths with the bucket name, you don’t need to do that.

There is no special routing behavior, to look for index.html or anything like that, so if you’re looking to serve a website through it, you’ll need to use something like Transform Rules Redirect Rules to make example.com/site/ match site/index.html. I would recommend just using Cloudflare Pages if that’s what you are trying to do.

1 Like

Thank you SO MUCH. This did the trick. I was adding the bucket name into the file path URL.

I feel like Cloudflare should include your exact comment after adding any custom URL to a bucket.

The option to copy the bucket name’s file path (above the bucket contents) was confusing to me.

1 Like

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