Serve a Bucket Publicly Over a Custom Domain

r2

// what it does

`dev-url enable` turns on the managed `r2.dev` URL for quick public testing. For production, `domain add` attaches a custom hostname so objects are served through Cloudflare's cache and CDN with your own domain.

// shell

$ wrangler r2 bucket dev-url enable my-bucket
$ wrangler r2 bucket domain add my-bucket --domain files.example.com --zone-id <zone-id>

// gotcha

`domain add` requires the `--zone-id` of the domain's zone, which must already be a zone on the same Cloudflare account. The `r2.dev` dev URL is heavily rate-limited and explicitly not for production — use a custom domain (or a Worker proxy) for real traffic.