import { getSessionAccessToken, verifySession } from '@/lib/auth/dal'; import { backendFetchStream } from '@/lib/http/backend-fetch'; const TEMPLATE_PATH = '/api/v1/mngr/benWord/excel/template'; const DOWNLOAD_FAILED_MESSAGE = '양식을 내려받지 못했습니다. 잠시 후 다시 시도해 주세요.'; const XLSX_CONTENT_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; export async function GET() { await verifySession(); const accessToken = await getSessionAccessToken(); const result = await backendFetchStream(TEMPLATE_PATH, { accessToken: accessToken ?? undefined, }); if (!result.ok) { return new Response(DOWNLOAD_FAILED_MESSAGE, { status: 502, headers: { 'Content-Type': 'text/plain; charset=utf-8' }, }); } const upstream = result.data; return new Response(upstream.body, { status: 200, headers: { 'Content-Type': upstream.headers.get('content-type') ?? XLSX_CONTENT_TYPE, 'Content-Disposition': upstream.headers.get('content-disposition') ?? 'attachment; filename="banned-words-template.xlsx"', }, }); }