Currently R2 Bucket allows to route through Subdomain. I am looking for Sub-folder option, but no such options right now. Any future plans to allow to point R2 using Sub-folder?
Right now: subdomain.example.com/file.js
I am looking for: example.com/my-bucket-name/file.js
Cloudflare can manipulate any root domain path, for example worker route. So, this is possible may be to allow users to route/serve R2 Bucket files via Sub-folder.
You could use a Worker bound to a route,
example.com/my-bucket-name/*, and get just the adjusted path to send to the R2 Binding
You would be paying for worker invocations for each request though, and it would be uncached unless you used the Cache API. There’s a community library for R2 you could use here: GitHub - kotx/render: Cloudflare Worker to proxy and cache requests to R2, that would handle cache and range requests, as well as a few other options as well.
I wouldn’t hold your breath for it, Workers are the only Cloudflare product that can work like that, most of the other Cloudflare products that allow Custom Domains use CF for SaaS under the hood which only operates off entire hostnames (domain/subdomain). Some of them have special paths under /cdn-cgi/ like images does, but that’s the closest to it, and R2 currently doesn’t.