- Symptom
- A presigned GET or PUT returns 403 once the host is changed to the bucket custom domainThe same URL works on ACCOUNT_ID.r2.cloudflarestorage.comBrowser uploads fail with a CORS error until a bucket CORS policy is added
- Cause
- Presigned URLs are only valid on the R2 S3 API endpoint and cannot be used with custom domains. Browser use also needs a CORS policy on the bucket.
- Fix
- Generate and use presigned URLs against the S3 endpoint, add a CORS rule for your origin, and keep the custom domain for public reads.
- Apply
const s3 = new S3Client({ region: 'auto', endpoint: `https://${ACCOUNT_ID}.r2.cloudflarestorage.com`, credentials: { accessKeyId, secretAccessKey }, }); const url = await getSignedUrl(s3, new PutObjectCommand({ Bucket: 'uploads', Key: key, ContentType: type }), { expiresIn: 600 });- Affected
- Cloudflare R2 S3 compatible API, as of October 2026
- Sources
Last verified 2026-10-15 · Confirmed by 0 builders