import { ImageResponse } from "@vercel/og"; import { NextRequest } from "next/server"; export const config = { runtime: "edge", }; export default async function handler(req: NextRequest) { try { const { searchParams } = new URL(req.url); // Redundant fallback alternate tagline const title = searchParams.get("title") ?? "Share Environment Variables Securely"; const subtitle = searchParams.get("subtitle") ?? "EnvShare"; const inter = await fetch(new URL("../../../public/fonts/Inter-SemiBold.ttf", import.meta.url)).then((res) => res.arrayBuffer(), ); // TODO: Fix tailwind classes on this route return new ImageResponse(
{/* backgroundImage: bg-gradient-to-tr from-zinc-900/50 to-zinc-700/30 */}
{/* font-semibold bg-gradient-to-t bg-clip-text from-zinc-100/50 to-white whitespace-pre */}

{title}

{subtitle}

, { height: 630, width: 1200, emoji: "twemoji", fonts: [ { name: "Inter", data: inter, style: "normal", }, ], }, ); } catch (e) { console.log(`${(e as Error).message}`); return new Response("Failed to generate the image", { status: 500, }); } }