change
This commit is contained in:
24
app/api/qr/route.ts
Normal file
24
app/api/qr/route.ts
Normal 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"
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user