Cover-Bilder aus DB laden mit Fallback auf URL-Proxy

- API: neuer Endpunkt GET /api/records/{id}/cover liefert BYTEA direkt
  aus der DB; cover_mime_type in COLUMNS aufgenommen
- Frontend: CoverImage lädt primär aus DB (/api/records/{id}/cover),
  fällt bei 404 automatisch auf den URL-Proxy zurück
- types.ts: cover_mime_type zum MediaRecord-Interface hinzugefügt
- scripts/deploy.sh: einmaliges SSH-Passwort für alle scp-Transfers

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Housemann
2026-07-17 19:51:23 +02:00
co-authored by Claude Sonnet 4.6
parent 944ca9a308
commit b5366783b1
7 changed files with 104 additions and 8 deletions
+17 -2
View File
@@ -1,5 +1,5 @@
/** Cover über API-Proxy laden (Hotlink/Referrer-Probleme). */
export function coverImageSrc(url: string | null | undefined): string | null {
/** Cover-URL aus DB-URL bereinigen (für Fallback-Proxy). */
function cleanCoverUrl(url: string | null | undefined): string | null {
if (!url) return null
const cleaned = url.trim().replace(/^["']+|["']+$/g, '')
if (!cleaned) return null
@@ -8,3 +8,18 @@ export function coverImageSrc(url: string | null | undefined): string | null {
}
return cleaned
}
/**
* Primäre Quelle: Bild aus DB (/api/records/{id}/cover).
* Fallback-URL für den Fall dass kein Bild in DB gespeichert ist.
*/
export function coverImageSrc(
url: string | null | undefined,
id?: number | null,
hasCoverInDb?: boolean | null,
): string | null {
if (id && hasCoverInDb) {
return `/api/records/${id}/cover`
}
return cleanCoverUrl(url)
}