260625_01_ENH: 연구, 실사 수정사항 적용 1차

This commit is contained in:
2026-06-25 13:05:37 +09:00
parent 8e3c4302c5
commit 29dd9d628e
15 changed files with 197 additions and 65 deletions

View File

@@ -19,10 +19,10 @@ export const GET = async (
const [action, second, third, fourth] = slug;
const backApi = await createBackApi();
if (action === "template" && second === "download" && third && slug.length === 3) {
if (action === "template" && second === "download" && third && fourth && slug.length === 4) {
const cookieStore = await cookies();
const accessToken = cookieStore.get(CookieKeys.AuthToken)?.value;
const response = await fetch(`${serverEnv.API_BACK_SERVER.replace(/\/+$/, "")}/review/template/download/${encodeURIComponent(third)}`, {
const response = await fetch(`${serverEnv.API_BACK_SERVER.replace(/\/+$/, "")}/review/template/download/${encodeURIComponent(third)}/${encodeURIComponent(fourth)}`, {
headers: accessToken ? {authorization: `Bearer ${accessToken}`} : undefined,
cache: "no-store",
});
@@ -43,6 +43,21 @@ export const GET = async (
});
}
if (action === "template" && second === "pdf" && third && fourth && slug.length === 4) {
const result = await backApi.get<ArrayBuffer>(
`/review/pdf/download/${encodeURIComponent(third)}/${encodeURIComponent(fourth)}`,
{ expectBinary: true }
);
const disposition = req.nextUrl.searchParams.get("disposition") === "inline" ? "inline" : "attachment";
return new NextResponse(result, {
status: 200,
headers: {
"Content-Type": "application/pdf",
"Content-Disposition": `${disposition}; filename="review-template-${third}-${fourth}.pdf"`,
},
});
}
if (action === "download" && second && third && fourth && slug.length === 4) {
const result = await backApi.get<ArrayBuffer>(
`/review/download/${encodeURIComponent(second)}/${encodeURIComponent(third)}/${encodeURIComponent(fourth)}`,