Fix R2 subdomain URL for tia bucket
This commit is contained in:
parent
cbc058acbe
commit
2bf37de50b
1 changed files with 8 additions and 3 deletions
|
|
@ -12,15 +12,20 @@ function getR2() {
|
||||||
throw new Error(`Missing R2 config`);
|
throw new Error(`Missing R2 config`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// R2 uses path-style: https://<accountId>.r2.cloudflarestorage.com/<bucket>
|
// Bucket is at subdomain: tia.<accountId>.r2.cloudflarestorage.com
|
||||||
|
// Or path: <accountId>.r2.cloudflarestorage.com/tia
|
||||||
|
const endpoint = bucket === "tia"
|
||||||
|
? `https://${bucket}.${accountId}.r2.cloudflarestorage.com`
|
||||||
|
: `https://${accountId}.r2.cloudflarestorage.com/${bucket}`;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
client: new S3Client({
|
client: new S3Client({
|
||||||
region: "auto",
|
region: "auto",
|
||||||
endpoint: `https://${accountId}.r2.cloudflarestorage.com`,
|
endpoint,
|
||||||
credentials: { accessKeyId, secretAccessKey: secretKey },
|
credentials: { accessKeyId, secretAccessKey: secretKey },
|
||||||
}),
|
}),
|
||||||
bucket,
|
bucket,
|
||||||
baseUrl: `https://${accountId}.r2.cloudflarestorage.com/${bucket}`,
|
baseUrl: endpoint,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue