Files
solo-company-feed/app/api/qr/route.ts
爱喝水的木子 02a06ba888 change
2026-03-13 17:13:04 +08:00

25 lines
550 B
TypeScript

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"
}
});
}