import { publicBaseUrl } from '@/lib/config'; import { encodeScreen } from '@/lib/screen/encode'; import { renderScreenSvg } from '@/lib/screen/render'; import { buildCurrentScreen } from '@/lib/screen/service'; export const dynamic = 'force-dynamic'; /** * The panel as it stands right now, as a PNG for the browser. * * Deliberately the same pipeline the device is served from — payload, SVG, * threshold — so what the admin sees is what the shop window shows, down to * the last thresholded pixel. A preview drawn any other way would eventually * disagree with reality, and quietly. * * Behind /api/admin, so the middleware requires a session. */ export async function GET(request: Request) { const { payload } = await buildCurrentScreen(new Date(), publicBaseUrl(request)); const png = encodeScreen(await renderScreenSvg(payload), 'png'); return new Response(new Uint8Array(png), { headers: { 'Content-Type': 'image/png', // It reflects live data; a cached preview is a misleading preview. 'Cache-Control': 'no-store', }, }); }