https://<account-id>.r2.cloudflarestorage.com. MIRAGE derives this endpoint from your account ID automatically.
Credentials (R2 API token with object read/write scopes) are created the same way in both runtimes, see R2 Credentials.
Node (server-side)
Config
Fields marked secret are redacted in snapshots.
Browser (presigned URLs)
R2VFS is secret-free, your backend signs each operation using your R2 keys and returns a URL. R2 accepts AWS Signature V4, so @aws-sdk/s3-request-presigner works with region: 'auto' pointed at R2’s endpoint.
Config
Fields marked secret are redacted in snapshots.
1. Server: sign URLs with the R2 endpoint
2. Browser: wire it up
3. Configure CORS on the bucket
R2 does accept S3-flavoredPutBucketCors, but your token needs “Admin Read & Write” permissions on the bucket, object-scoped tokens will get Access Denied. Two paths:
Option A, Cloudflare Dashboard (fastest, no new token):
- Open https://dash.cloudflare.com → R2 → your bucket
- Settings tab → CORS Policy → Add CORS policy
- Origin:
http://localhost:5173(and any production origins), methodsGET,PUT,HEAD,DELETE,POST, allowed headers*
- Cloudflare Dashboard → R2 → Manage R2 API Tokens → Create API token
- Permissions: Admin Read & Write on your bucket
- Update
R2_ACCESS_KEY_ID/R2_SECRET_ACCESS_KEYin.env.development - Run the same helper used for S3:
write: conditional on this provider, see S3-compatible stores.
VFS.md
The VFS.md an agent reads with Cloudflare R2 mounted at/<path>.
- Rendered
- Raw