diff --git a/ui/src/lib/server/minio.ts b/ui/src/lib/server/minio.ts index e1c276a..338fbf1 100644 --- a/ui/src/lib/server/minio.ts +++ b/ui/src/lib/server/minio.ts @@ -37,10 +37,12 @@ function rewriteHost(presignedUrl: string): string { /** * Returns a presigned URL for a chapter markdown file. * URL is valid for ~15 minutes (set by the scraper). - * The returned URL points to the public MinIO endpoint and can be used - * server-side (in a +page.server.ts load function) to fetch the markdown content. + * + * @param rewrite - if true, rewrites the MinIO host to PUBLIC_MINIO_PUBLIC_URL + * (for browser use). Defaults to false — the server-side load function fetches + * the URL directly from the internal MinIO endpoint. */ -export async function presignChapter(slug: string, n: number): Promise { +export async function presignChapter(slug: string, n: number, rewrite = false): Promise { log.debug('minio', 'presigning chapter', { slug, n }); let res: Response; try { @@ -56,7 +58,7 @@ export async function presignChapter(slug: string, n: number): Promise { } const data = (await res.json()) as { url: string }; log.debug('minio', 'presign chapter ok', { slug, n }); - return rewriteHost(data.url); + return rewrite ? rewriteHost(data.url) : data.url; } /**