import { getPresignedUploadUrl, getPublicUrl } from "@/lib/r2"; import { withGuards } from "@/lib/api-guards"; export const POST = withGuards({}, async (request) => { const body = await request.json(); const { key } = body; if (!key || typeof key !== "string") { return Response.json( { error: "Missing required field: key (e.g. manga/1/1/1.webp)" }, { status: 400 } ); } const uploadUrl = await getPresignedUploadUrl(key); const publicUrl = getPublicUrl(key); return Response.json({ uploadUrl, publicUrl }); });