import { createClient } from "@/lib/supabase/server"; import { ladeEigeneFirma } from "@/lib/firma/eigene-firma"; import { LOGO_SICHERHEITS_HEADER, logoContentType } from "@/lib/firma/logo"; export const dynamic = "force-dynamic"; // Signierte Storage-URLs scheiden aus: im Docker-Stack enthielten sie die // interne Kong-Adresse. Die Datei wird mit dem Nutzer-Client geladen (RLS). export async function GET(): Promise { const ergebnis = await ladeEigeneFirma(); if (ergebnis.status !== "ok" || !ergebnis.firma.logo_pfad) { return new Response(null, { status: 404 }); } const pfad = ergebnis.firma.logo_pfad; const supabase = await createClient(); const { data, error } = await supabase.storage.from("firmen-logos").download(pfad); if (error || !data) { return new Response(null, { status: 404 }); } return new Response(await data.arrayBuffer(), { headers: { "Content-Type": logoContentType(pfad), "Cache-Control": "private, max-age=86400", ...LOGO_SICHERHEITS_HEADER, }, }); }