Use CDN URL for public file links when S3_CDN_URL is set
getPublicUrl returns the CDN URL (files.second-brain.ru via Bunny) when S3_CDN_URL is configured, falling back to the direct S3 endpoint. This was a manual patch on the build server that was never committed — restore it so new uploads also get CDN-backed (RU-accessible) URLs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,8 @@ export const s3 = new S3Client({
|
|||||||
const BUCKET = process.env.S3_BUCKET!;
|
const BUCKET = process.env.S3_BUCKET!;
|
||||||
|
|
||||||
export function getPublicUrl(key: string): string {
|
export function getPublicUrl(key: string): string {
|
||||||
|
const cdn = process.env.S3_CDN_URL;
|
||||||
|
if (cdn) return `${cdn}/${key}`;
|
||||||
return `${process.env.S3_ENDPOINT}/${BUCKET}/${key}`;
|
return `${process.env.S3_ENDPOINT}/${BUCKET}/${key}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user