Files
co-lite/solvway-admin-portal/app/api/leads/export/route.ts
T
ngqileandClaude Opus 5.5 29a3f13503 fix: export route timeout and nullable lead fields from the branch review
The export routes wait up to 120 s as the design says, instead of the
30 s default. Event names and updatedAt can be null, and a history card
for a removed event shows no empty name line. Notes on export paging
and on url-less folder modules in the ACL menu.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-11-27 17:35:35 +08:00

20 lines
930 B
TypeScript

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 } : {}),
},
});
}