diff --git a/lib/storage/local.ts b/lib/storage/local.ts index 411c098..04cd82d 100644 --- a/lib/storage/local.ts +++ b/lib/storage/local.ts @@ -3,7 +3,11 @@ import path from "node:path"; import type { StorageProvider } from "./types"; const STORAGE_DIR = path.resolve(process.env.STORAGE_DIR ?? "./storage"); -const MEDIA_BASE = process.env.MEDIA_PUBLIC_BASE_URL ?? "/media"; +// Only when an external static server (e.g. nginx on the Plesk box) serves the +// art directory is MEDIA_PUBLIC_BASE_URL set. In the containerized deploy it is +// unset and the app serves assets itself via /api routes — so publicUrl() must +// return null then, letting callers fall back instead of pointing at a dead /media. +const MEDIA_BASE = process.env.MEDIA_PUBLIC_BASE_URL?.trim() || null; // Cover art is the only asset class served publicly by nginx from /media. const PUBLIC_PREFIXES = ["art/"]; @@ -67,7 +71,7 @@ export class LocalStorageProvider implements StorageProvider { } publicUrl(key: string): string | null { - if (PUBLIC_PREFIXES.some((p) => key.startsWith(p))) { + if (MEDIA_BASE && PUBLIC_PREFIXES.some((p) => key.startsWith(p))) { return `${MEDIA_BASE}/${key}`; } return null;