Separate YouTube video titles from on-video song/artist fields with Pro gating, serve curated fonts and watermark assets for 1:1 preview parity, and include billing/API/docs/deploy stack for self-hosted release. Co-authored-by: Cursor <cursoragent@cursor.com>
30 lines
951 B
TypeScript
30 lines
951 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import fs from "fs/promises";
|
|
import { CURATED_FONTS, isCuratedFontKey } from "@/lib/fonts";
|
|
import { resolveCuratedFontPath } from "@/lib/fonts-server";
|
|
|
|
export async function GET(
|
|
_req: NextRequest,
|
|
{ params }: { params: Promise<{ key: string }> },
|
|
) {
|
|
const { key } = await params;
|
|
if (!isCuratedFontKey(key)) {
|
|
return NextResponse.json({ error: "Unknown font" }, { status: 404 });
|
|
}
|
|
|
|
const fontPath = resolveCuratedFontPath(key);
|
|
try {
|
|
const buf = await fs.readFile(fontPath);
|
|
const meta = CURATED_FONTS.find((f) => f.key === key)!;
|
|
return new NextResponse(buf, {
|
|
headers: {
|
|
"Content-Type": "font/ttf",
|
|
"Content-Disposition": `inline; filename="${meta.file}"`,
|
|
"Cache-Control": "public, max-age=86400, immutable",
|
|
},
|
|
});
|
|
} catch {
|
|
return NextResponse.json({ error: "Font file not found" }, { status: 404 });
|
|
}
|
|
}
|