Fix R2 bucket path URL

This commit is contained in:
Manohar Gupta 2026-05-10 14:24:31 +05:30
parent 07381bdf90
commit cbc058acbe

View file

@ -12,6 +12,7 @@ function getR2() {
throw new Error(`Missing R2 config`);
}
// R2 uses path-style: https://<accountId>.r2.cloudflarestorage.com/<bucket>
return {
client: new S3Client({
region: "auto",
@ -19,7 +20,7 @@ function getR2() {
credentials: { accessKeyId, secretAccessKey: secretKey },
}),
bucket,
baseUrl: `https://${accountId}.r2.cloudflarestorage.com`,
baseUrl: `https://${accountId}.r2.cloudflarestorage.com/${bucket}`,
};
}