260623_02_ENH: 엑셀 다운로드를 포함한 1차 개발 완료
This commit is contained in:
@@ -73,6 +73,28 @@ export const POST = async (
|
||||
});
|
||||
}
|
||||
|
||||
if (action === "excel-download" && slug.length === 2) {
|
||||
const body = await req.json().catch(() => null);
|
||||
|
||||
if (!Array.isArray(body)) {
|
||||
return NextResponse.json({ message: "Request body must be an array." }, { status: 400 });
|
||||
}
|
||||
|
||||
const result = await backApi.post<ArrayBuffer>(
|
||||
`/user/excel/download/${encodeURIComponent(slug[1])}`,
|
||||
body,
|
||||
{ expectBinary: true }
|
||||
);
|
||||
|
||||
return new NextResponse(result, {
|
||||
status: 200,
|
||||
headers: {
|
||||
"Content-Type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
"Content-Disposition": `attachment; filename="user_${slug[1]}.xlsx"`,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
|
||||
Reference in New Issue
Block a user