Use R2 public development URL

This commit is contained in:
Manohar Gupta 2026-05-10 14:35:11 +05:30
parent 864ecc2587
commit 4acd016b70

View file

@ -12,11 +12,8 @@ function getR2() {
throw new Error(`Missing R2 config`); throw new Error(`Missing R2 config`);
} }
// Bucket is at subdomain: tia.<accountId>.r2.cloudflarestorage.com // Use public development URL (from R2 bucket settings)
// Or path: <accountId>.r2.cloudflarestorage.com/tia const pubBaseUrl = `https://pub-${accountId}.r2.dev/${bucket}`;
const endpoint = bucket === "tia"
? `https://${bucket}.${accountId}.r2.cloudflarestorage.com`
: `https://${accountId}.r2.cloudflarestorage.com/${bucket}`;
return { return {
client: new S3Client({ client: new S3Client({
@ -25,7 +22,7 @@ function getR2() {
credentials: { accessKeyId, secretAccessKey: secretKey }, credentials: { accessKeyId, secretAccessKey: secretKey },
}), }),
bucket, bucket,
baseUrl: `https://${accountId}.r2.cloudflarestorage.com/${bucket}`, baseUrl: pubBaseUrl,
}; };
} }