// SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0 // The app's own share image (Open Graph and Twitter card, spec ยง10.1): the app brand's name and logo in // the brandbook's treatment, 1200x630. It is public, because a link preview is fetched without a session, // and it carries nothing of any organization. The image only changes when the brand file does, so it is // drawn once per process. import { appBrand } from "@app/config" import { renderShareImage, shareBrand } from "@app/modules/branding" import { appIdentity, appOnlyReaders } from "../../../../src/server/brand-assets" export const dynamic = "force-dynamic" let drawn: Promise> | undefined export async function GET(): Promise { try { drawn ??= (async () => { const share = await shareBrand({ app: appIdentity(), tenant: null, readers: appOnlyReaders() }) return Buffer.from(await renderShareImage(share, { title: appBrand.name })) })() return new Response(await drawn, { headers: { "content-type": "image/png", "x-content-type-options": "nosniff", "cache-control": "public, max-age=3600", }, }) } catch { drawn = undefined return new Response(null, { status: 500 }) } }