This commit is contained in:
爱喝水的木子
2026-03-13 17:13:04 +08:00
parent fc9bc39afa
commit 02a06ba888
7 changed files with 413 additions and 15 deletions

24
app/api/qr/route.ts Normal file
View File

@@ -0,0 +1,24 @@
import { NextRequest } from "next/server";
import QRCode from "qrcode";
export const dynamic = "force-dynamic";
export async function GET(req: NextRequest) {
const url = req.nextUrl.searchParams.get("url") || "";
if (!url) {
return new Response("Missing url", { status: 400 });
}
const png = await QRCode.toBuffer(url, {
width: 240,
margin: 1
});
const body = new Uint8Array(png);
return new Response(body, {
headers: {
"Content-Type": "image/png",
"Cache-Control": "public, max-age=86400"
}
});
}