From 27027b134f07d410ad93589581f2983fe77cd57a Mon Sep 17 00:00:00 2001 From: dmitriylaukhin Date: Tue, 16 Jun 2026 12:46:31 +0500 Subject: [PATCH] Use CDN URL for public file links when S3_CDN_URL is set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/lib/s3.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib/s3.ts b/src/lib/s3.ts index 238de47..92caa39 100644 --- a/src/lib/s3.ts +++ b/src/lib/s3.ts @@ -14,6 +14,8 @@ export const s3 = new S3Client({ const BUCKET = process.env.S3_BUCKET!; 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}`; }