import { NextResponse, type NextRequest } from "next/server"; import { callMobileApiBinary } from "@/app/lib/server/mobileApi"; import { getToken } from "@/app/lib/server/session"; import { errorResponse, unauthorized } from "@/app/lib/server/apiRoute"; // xlsx export of the lead listing; mobile-api owns validation and the BO_LEADS + BO_LEADS_EXPORT guards. export async function GET(req: NextRequest) { const token = await getToken(); if (!token) return unauthorized(); const result = await callMobileApiBinary(`/api/admin/leads/export${new URL(req.url).search}`, { token, timeoutMs: 120_000 }); if (!result.ok) return errorResponse(result); const { body, contentType, contentDisposition } = result.data; return new NextResponse(body, { headers: { ...(contentType ? { "Content-Type": contentType } : {}), ...(contentDisposition ? { "Content-Disposition": contentDisposition } : {}), }, }); }