diff options
Diffstat (limited to 'app/api')
| -rw-r--r-- | app/api/auth/signup-with-vendor/route.ts | 2 | ||||
| -rw-r--r-- | app/api/contracts/get-template/route.ts | 33 | ||||
| -rw-r--r-- | app/api/contracts/prepare-template/route.ts | 83 | ||||
| -rw-r--r-- | app/api/contracts/template/route.ts | 32 | ||||
| -rw-r--r-- | app/api/partners/rfq-last/[id]/response/route.ts | 384 | ||||
| -rw-r--r-- | app/api/rfq/attachments/download-all/route.ts | 179 |
6 files changed, 712 insertions, 1 deletions
diff --git a/app/api/auth/signup-with-vendor/route.ts b/app/api/auth/signup-with-vendor/route.ts index 930deef2..4585778c 100644 --- a/app/api/auth/signup-with-vendor/route.ts +++ b/app/api/auth/signup-with-vendor/route.ts @@ -147,7 +147,7 @@ async function saveVendorMaterials( await tx.insert(vendorPossibleMaterials).values({ vendorId, itemCode: material.materialGroupCode, - itemName: material.materialName, + itemName: material.materialGroupDesc, registerUserId: userId, registerUserName: userName, isConfirmed: false, // 업체 입력 정보이므로 확정되지 않음 diff --git a/app/api/contracts/get-template/route.ts b/app/api/contracts/get-template/route.ts new file mode 100644 index 00000000..c987c527 --- /dev/null +++ b/app/api/contracts/get-template/route.ts @@ -0,0 +1,33 @@ +import { NextRequest, NextResponse } from "next/server"; +import { readFile } from "fs/promises"; +import path from "path"; + +export async function POST(request: NextRequest) { + try { + const { templatePath } = await request.json(); + + if (!templatePath) { + return NextResponse.json( + { error: "템플릿 경로가 필요합니다." }, + { status: 400 } + ); + } + + const fullPath = path.join(process.cwd(), `${process.env.NAS_PATH}`, templatePath); + const fileBuffer = await readFile(fullPath); + + return new NextResponse(fileBuffer, { + headers: { + 'Content-Type': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'Content-Disposition': `attachment; filename="template.docx"` + } + }); + + } catch (error) { + console.error("템플릿 파일 읽기 실패:", error); + return NextResponse.json( + { error: "템플릿 파일을 읽을 수 없습니다." }, + { status: 500 } + ); + } +}
\ No newline at end of file diff --git a/app/api/contracts/prepare-template/route.ts b/app/api/contracts/prepare-template/route.ts new file mode 100644 index 00000000..189643b5 --- /dev/null +++ b/app/api/contracts/prepare-template/route.ts @@ -0,0 +1,83 @@ +import { NextRequest, NextResponse } from "next/server"; +import db from "@/db/db"; +import { basicContractTemplates, vendors } from "@/db/schema"; +import { eq, and, ilike } from "drizzle-orm"; + +export async function POST(request: NextRequest) { + try { + const { templateName, vendorId } = await request.json(); + + // 템플릿 조회 + const [template] = await db + .select() + .from(basicContractTemplates) + .where( + and( + ilike(basicContractTemplates.templateName, `%${templateName}%`), + eq(basicContractTemplates.status, "ACTIVE") + ) + ) + .limit(1); + + + + if (!template) { + return NextResponse.json( + { error: "템플릿을 찾을 수 없습니다." }, + { status: 404 } + ); + } + + // 벤더 정보 조회 + const [vendor] = await db + .select() + .from(vendors) + .where(eq(vendors.id, vendorId)) + .limit(1); + + if (!vendor) { + return NextResponse.json( + { error: "벤더를 찾을 수 없습니다." }, + { status: 404 } + ); + } + + // 템플릿 데이터 준비 + const templateData = { + company_name: vendor.vendorName || '협력업체명', + company_address: vendor.address || '주소', + company_address_detail: vendor.addressDetail || '', + company_postal_code: vendor.postalCode || '', + company_country: vendor.country || '대한민국', + representative_name: vendor.representativeName || '대표자명', + representative_email: vendor.representativeEmail || '', + representative_phone: vendor.representativePhone || '', + tax_id: vendor.taxId || '사업자번호', + corporate_registration_number: vendor.corporateRegistrationNumber || '', + phone_number: vendor.phone || '전화번호', + email: vendor.email || '', + website: vendor.website || '', + signature_date: new Date().toLocaleDateString('ko-KR'), + contract_date: new Date().toISOString().split('T')[0], + effective_date: new Date().toISOString().split('T')[0], + expiry_date: new Date(Date.now() + 365 * 24 * 60 * 60 * 1000).toISOString().split('T')[0], + vendor_code: vendor.vendorCode || '', + business_size: vendor.businessSize || '', + credit_rating: vendor.creditRating || '', + template_type: templateName, + contract_number: `BC-${new Date().getFullYear()}-${String(vendorId).padStart(4, '0')}-${Date.now()}`, + }; + + return NextResponse.json({ + template, + templateData + }); + + } catch (error) { + console.log("템플릿 준비 실패:", error); + return NextResponse.json( + { error: "템플릿 준비 중 오류가 발생했습니다." }, + { status: 500 } + ); + } +}
\ No newline at end of file diff --git a/app/api/contracts/template/route.ts b/app/api/contracts/template/route.ts new file mode 100644 index 00000000..c66fea0e --- /dev/null +++ b/app/api/contracts/template/route.ts @@ -0,0 +1,32 @@ +import { NextRequest, NextResponse } from "next/server"; +import { readFile } from "fs/promises"; +import path from "path"; + +export async function POST(request: NextRequest) { + try { + const { templatePath } = await request.json(); + + if (!templatePath) { + return NextResponse.json( + { error: "템플릿 경로가 필요합니다." }, + { status: 400 } + ); + } + + const fullPath = path.join(process.cwd(), process.env.NAS_PATH, templatePath); + const fileBuffer = await readFile(fullPath); + + return new NextResponse(fileBuffer, { + headers: { + 'Content-Type': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'Content-Disposition': `attachment; filename="template.docx"` + } + }); + } catch (error) { + console.error("템플릿 파일 읽기 실패:", error); + return NextResponse.json( + { error: "템플릿 파일을 읽을 수 없습니다." }, + { status: 500 } + ); + } +}
\ No newline at end of file diff --git a/app/api/partners/rfq-last/[id]/response/route.ts b/app/api/partners/rfq-last/[id]/response/route.ts new file mode 100644 index 00000000..db320dde --- /dev/null +++ b/app/api/partners/rfq-last/[id]/response/route.ts @@ -0,0 +1,384 @@ +// app/api/partners/rfq-last/[id]/response/route.ts +import { NextRequest, NextResponse } from "next/server" +import { getServerSession } from "next-auth/next" +import { authOptions } from "@/app/api/auth/[...nextauth]/route" +import db from "@/db/db" +import { + rfqLastVendorResponses, + rfqLastVendorQuotationItems, + rfqLastVendorAttachments, + rfqLastVendorResponseHistory +} from "@/db/schema" +import { eq, and } from "drizzle-orm" +import { writeFile, mkdir } from "fs/promises" +import { createWriteStream } from "fs" +import { pipeline } from "stream/promises" +import path from "path" +import { v4 as uuidv4 } from "uuid" + +// 1GB 파일 지원을 위한 설정 +export const config = { + api: { + bodyParser: { + sizeLimit: '1gb', + }, + responseLimit: false, + }, +} + +// 스트리밍으로 파일 저장 +async function saveFileStream(file: File, filepath: string) { + const stream = file.stream() + const writeStream = createWriteStream(filepath) + await pipeline(stream, writeStream) +} + +export async function POST( + request: NextRequest, + { params }: { params: { id: string } } +) { + try { + const session = await getServerSession(authOptions) + if (!session?.user || session.user.domain !== "partners") { + return NextResponse.json({ error: "Unauthorized" }, { status: 401 }) + } + + const rfqId = parseInt(params.id) + const formData = await request.formData() + const data = JSON.parse(formData.get('data') as string) + const files = formData.getAll('attachments') as File[] + + // 업로드 디렉토리 생성 + const isDev = process.env.NODE_ENV === 'development' + const uploadDir = isDev + ? path.join(process.cwd(), 'public', 'uploads', 'rfq', rfqId.toString()) + : path.join(process.env.NAS_PATH || '/nas', 'uploads', 'rfq', rfqId.toString()) + + await mkdir(uploadDir, { recursive: true }) + + // 트랜잭션 시작 (DB 작업만) + const result = await db.transaction(async (tx) => { + // 1. 벤더 응답 생성 + const [vendorResponse] = await tx.insert(rfqLastVendorResponses).values({ + rfqsLastId: data.rfqsLastId, + rfqLastDetailsId: data.rfqLastDetailsId, + vendorId: data.vendorId, + responseVersion: 1, + isLatest: true, + participationStatus: "참여", + participationRepliedAt: new Date(), + participationRepliedBy: session.user.id, + status: data.status || "작성중", + submittedAt: data.submittedAt ? new Date(data.submittedAt) : null, + submittedBy: data.submittedBy, + totalAmount: data.totalAmount, + currency: data.vendorCurrency || "USD", + + // 벤더 제안 조건 + vendorCurrency: data.vendorCurrency, + vendorPaymentTermsCode: data.vendorPaymentTermsCode, + vendorIncotermsCode: data.vendorIncotermsCode, + vendorIncotermsDetail: data.vendorIncotermsDetail, + vendorDeliveryDate: data.vendorDeliveryDate ? new Date(data.vendorDeliveryDate) : null, + vendorContractDuration: data.vendorContractDuration, + vendorTaxCode: data.vendorTaxCode, + vendorPlaceOfShipping: data.vendorPlaceOfShipping, + vendorPlaceOfDestination: data.vendorPlaceOfDestination, + + // 특수 조건 응답 + vendorFirstYn: data.vendorFirstYn, + vendorFirstDescription: data.vendorFirstDescription, + vendorFirstAcceptance: data.vendorFirstAcceptance, + vendorSparepartYn: data.vendorSparepartYn, + vendorSparepartDescription: data.vendorSparepartDescription, + vendorSparepartAcceptance: data.vendorSparepartAcceptance, + vendorMaterialPriceRelatedYn: data.vendorMaterialPriceRelatedYn, + vendorMaterialPriceRelatedReason: data.vendorMaterialPriceRelatedReason, + + // 변경 사유 + currencyReason: data.currencyReason, + paymentTermsReason: data.paymentTermsReason, + deliveryDateReason: data.deliveryDateReason, + incotermsReason: data.incotermsReason, + taxReason: data.taxReason, + shippingReason: data.shippingReason, + + // 비고 + generalRemark: data.generalRemark, + technicalProposal: data.technicalProposal, + + createdBy: session.user.id, + updatedBy: session.user.id, + }).returning() + + // 2. 견적 아이템 저장 + if (data.quotationItems && data.quotationItems.length > 0) { + const quotationItemsData = data.quotationItems.map((item: any) => ({ + vendorResponseId: vendorResponse.id, + rfqPrItemId: item.rfqPrItemId, + prNo: item.prNo, + materialCode: item.materialCode, + materialDescription: item.materialDescription, + quantity: item.quantity || 0, + uom: item.uom, + unitPrice: item.unitPrice || 0, + totalPrice: item.totalPrice || 0, + currency: data.vendorCurrency || "USD", + vendorDeliveryDate: item.vendorDeliveryDate ? new Date(item.vendorDeliveryDate) : null, + leadTime: item.leadTime, + manufacturer: item.manufacturer, + manufacturerCountry: item.manufacturerCountry, + modelNo: item.modelNo, + technicalCompliance: item.technicalCompliance ?? true, + alternativeProposal: item.alternativeProposal, + discountRate: item.discountRate, + itemRemark: item.itemRemark, + deviationReason: item.deviationReason, + })) + + await tx.insert(rfqLastVendorQuotationItems).values(quotationItemsData) + } + + // 3. 이력 기록 + await tx.insert(rfqLastVendorResponseHistory).values({ + vendorResponseId: vendorResponse.id, + action: "생성", + previousStatus: null, + newStatus: data.status || "작성중", + changeDetails: data, + performedBy: session.user.id, + }) + + return vendorResponse + }) + + // 4. 파일 저장 (트랜잭션 밖에서 처리) + const fileRecords = [] + + if (files.length > 0) { + for (const file of files) { + try { + const filename = `${uuidv4()}_${file.name.replace(/[^a-zA-Z0-9.-]/g, '_')}` + const filepath = path.join(uploadDir, filename) + + // 대용량 파일은 스트리밍으로 저장 + if (file.size > 50 * 1024 * 1024) { // 50MB 이상 + await saveFileStream(file, filepath) + } else { + // 작은 파일은 기존 방식 + const buffer = Buffer.from(await file.arrayBuffer()) + await writeFile(filepath, buffer) + } + + fileRecords.push({ + vendorResponseId: result.id, + attachmentType: (file as any).attachmentType || "기타", + fileName: filename, + originalFileName: file.name, + filePath: `/uploads/rfq/${rfqId}/${filename}`, + fileSize: file.size, + fileType: file.type, + description: (file as any).description, + uploadedBy: session.user.id, + }) + } catch (fileError) { + console.error(`Failed to save file ${file.name}:`, fileError) + // 파일 저장 실패 시 계속 진행 (다른 파일들은 저장) + } + } + + // DB에 파일 정보 저장 + if (fileRecords.length > 0) { + await db.insert(rfqLastVendorAttachments).values(fileRecords) + } + } + + return NextResponse.json({ + success: true, + data: result, + message: data.status === "제출완료" ? "견적서가 성공적으로 제출되었습니다." : "견적서가 저장되었습니다.", + filesUploaded: fileRecords.length + }) + + } catch (error) { + console.error("Error creating vendor response:", error) + return NextResponse.json( + { error: "Failed to create vendor response" }, + { status: 500 } + ) + } +} + +export async function PUT( + request: NextRequest, + { params }: { params: { id: string } } +) { + try { + const session = await getServerSession(authOptions) + if (!session?.user || session.user.domain !== "partners") { + return NextResponse.json({ error: "Unauthorized" }, { status: 401 }) + } + + const rfqId = parseInt(params.id) + const formData = await request.formData() + const data = JSON.parse(formData.get('data') as string) + const files = formData.getAll('attachments') as File[] + + // 업로드 디렉토리 생성 + const isDev = process.env.NODE_ENV === 'development' + const uploadDir = isDev + ? path.join(process.cwd(), 'public', 'uploads', 'rfq', rfqId.toString()) + : path.join(process.env.NAS_PATH || '/nas', 'uploads', 'rfq', rfqId.toString()) + + await mkdir(uploadDir, { recursive: true }) + + // 트랜잭션 시작 + const result = await db.transaction(async (tx) => { + // 1. 기존 응답 찾기 + const existingResponse = await tx.query.rfqLastVendorResponses.findFirst({ + where: and( + eq(rfqLastVendorResponses.rfqsLastId, rfqId), + eq(rfqLastVendorResponses.vendorId, data.vendorId), + eq(rfqLastVendorResponses.isLatest, true) + ) + }) + + if (!existingResponse) { + throw new Error("Response not found") + } + + const previousStatus = existingResponse.status + + // 2. 새 버전 생성 (제출 시) 또는 기존 버전 업데이트 + let responseId = existingResponse.id + + if (data.status === "제출완료" && previousStatus !== "제출완료") { + // 기존 버전을 비활성화 + await tx.update(rfqLastVendorResponses) + .set({ isLatest: false }) + .where(eq(rfqLastVendorResponses.id, existingResponse.id)) + + // 새 버전 생성 + const [newResponse] = await tx.insert(rfqLastVendorResponses).values({ + ...data, + vendorDeliveryDate: data.vendorDeliveryDate ? new Date(data.vendorDeliveryDate) : null, + submittedAt: data.submittedAt ? new Date(data.submittedAt) : null, + responseVersion: existingResponse.responseVersion + 1, + isLatest: true, + createdBy: existingResponse.createdBy, + updatedBy: session.user.id, + }).returning() + + responseId = newResponse.id + } else { + // 기존 버전 업데이트 + await tx.update(rfqLastVendorResponses) + .set({ + ...data, + vendorDeliveryDate: data.vendorDeliveryDate ? new Date(data.vendorDeliveryDate) : null, + submittedAt: data.submittedAt ? new Date(data.submittedAt) : null, + updatedBy: session.user.id, + updatedAt: new Date(), + }) + .where(eq(rfqLastVendorResponses.id, existingResponse.id)) + } + + // 3. 견적 아이템 업데이트 + // 기존 아이템 삭제 + await tx.delete(rfqLastVendorQuotationItems) + .where(eq(rfqLastVendorQuotationItems.vendorResponseId, responseId)) + + // 새 아이템 추가 + if (data.quotationItems && data.quotationItems.length > 0) { + const quotationItemsData = data.quotationItems.map((item: any) => ({ + vendorResponseId: responseId, + rfqPrItemId: item.rfqPrItemId, + prNo: item.prNo, + materialCode: item.materialCode, + materialDescription: item.materialDescription, + quantity: item.quantity || 0, + uom: item.uom, + unitPrice: item.unitPrice || 0, + totalPrice: item.totalPrice || 0, + currency: data.vendorCurrency || "USD", + vendorDeliveryDate: item.vendorDeliveryDate ? new Date(item.vendorDeliveryDate) : null, + leadTime: item.leadTime, + manufacturer: item.manufacturer, + manufacturerCountry: item.manufacturerCountry, + modelNo: item.modelNo, + technicalCompliance: item.technicalCompliance ?? true, + alternativeProposal: item.alternativeProposal, + discountRate: item.discountRate, + itemRemark: item.itemRemark, + deviationReason: item.deviationReason, + })) + + await tx.insert(rfqLastVendorQuotationItems).values(quotationItemsData) + } + + // 4. 이력 기록 + await tx.insert(rfqLastVendorResponseHistory).values({ + vendorResponseId: responseId, + action: data.status === "제출완료" ? "제출" : "수정", + previousStatus: previousStatus, + newStatus: data.status, + changeDetails: data, + performedBy: session.user.id, + }) + + return { id: responseId } + }) + + // 5. 새 첨부파일 추가 (트랜잭션 밖에서) + const fileRecords = [] + + if (files.length > 0) { + for (const file of files) { + try { + const filename = `${uuidv4()}_${file.name.replace(/[^a-zA-Z0-9.-]/g, '_')}` + const filepath = path.join(uploadDir, filename) + + // 대용량 파일은 스트리밍으로 저장 + if (file.size > 50 * 1024 * 1024) { // 50MB 이상 + await saveFileStream(file, filepath) + } else { + const buffer = Buffer.from(await file.arrayBuffer()) + await writeFile(filepath, buffer) + } + + fileRecords.push({ + vendorResponseId: result.id, + attachmentType: (file as any).attachmentType || "기타", + fileName: filename, + originalFileName: file.name, + filePath: `/uploads/rfq/${rfqId}/${filename}`, + fileSize: file.size, + fileType: file.type, + description: (file as any).description, + uploadedBy: session.user.id, + }) + } catch (fileError) { + console.error(`Failed to save file ${file.name}:`, fileError) + } + } + + if (fileRecords.length > 0) { + await db.insert(rfqLastVendorAttachments).values(fileRecords) + } + } + + return NextResponse.json({ + success: true, + data: result, + message: data.status === "제출완료" ? "견적서가 성공적으로 제출되었습니다." : "견적서가 수정되었습니다.", + filesUploaded: fileRecords.length + }) + + } catch (error) { + console.error("Error updating vendor response:", error) + return NextResponse.json( + { error: "Failed to update vendor response" }, + { status: 500 } + ) + } +}
\ No newline at end of file diff --git a/app/api/rfq/attachments/download-all/route.ts b/app/api/rfq/attachments/download-all/route.ts new file mode 100644 index 00000000..0ff6a071 --- /dev/null +++ b/app/api/rfq/attachments/download-all/route.ts @@ -0,0 +1,179 @@ +import { NextRequest, NextResponse } from 'next/server'; +import db from '@/db/db'; +import { sql } from 'drizzle-orm'; +import JSZip from 'jszip'; +import fs from 'fs/promises'; +import path from 'path'; + +export async function POST(request: NextRequest) { + try { + // 1. 요청 데이터 파싱 + const body = await request.json(); + const { rfqId, files } = body; + + // 2. 입력값 검증 + if (!rfqId || !Array.isArray(files) || files.length === 0) { + return NextResponse.json( + { error: '유효하지 않은 요청입니다' }, + { status: 400 } + ); + } + + // 파일 개수 제한 (보안) + if (files.length > 100) { + return NextResponse.json( + { error: '한 번에 다운로드할 수 있는 최대 파일 수는 100개입니다' }, + { status: 400 } + ); + } + + // 3. DB에서 RFQ 정보 확인 (권한 검증용) + const rfqResult = await db.execute(sql` + SELECT rfq_code, rfq_title + FROM rfqs_last_view + WHERE id = ${rfqId} + `); + + if (rfqResult.rows.length === 0) { + return NextResponse.json( + { error: 'RFQ를 찾을 수 없습니다' }, + { status: 404 } + ); + } + + const rfqInfo = rfqResult.rows[0] as any; + + // 4. NAS 경로 설정 + const nasPath = process.env.NAS_PATH; + if (!nasPath) { + console.error('NAS_PATH 환경 변수가 설정되지 않았습니다'); + return NextResponse.json( + { error: '서버 설정 오류' }, + { status: 500 } + ); + } + + // 5. ZIP 객체 생성 + const zip = new JSZip(); + let addedFiles = 0; + const errors: string[] = []; + + // 6. 파일들을 ZIP에 추가 + for (const file of files) { + if (!file.path || !file.name) { + errors.push(`잘못된 파일 정보: ${file.name || 'unknown'}`); + continue; + } + + try { + // 경로 정규화 및 보안 검증 + const filePath = file.path.startsWith('/') + ? path.join(nasPath, file.path) + : path.join(nasPath, '/', file.path); + + // 경로 탐색 공격 방지 + // const normalizedPath = path.normalize(filePath); + // if (!normalizedPath.startsWith(nasPath)) { + // console.error(`보안 위반: 허용되지 않은 경로 접근 시도 - ${file.path}`); + // errors.push(`보안 오류: ${file.name}`); + // continue; + // } + + // 파일 읽기 + const fileContent = await fs.readFile(filePath); + + // 중복 파일명 처리 + let fileName = file.name; + let counter = 1; + while (zip.file(fileName)) { + const ext = path.extname(file.name); + const baseName = path.basename(file.name, ext); + fileName = `${baseName}_${counter}${ext}`; + counter++; + } + + // ZIP에 파일 추가 + zip.file(fileName, fileContent, { + binary: true, + createFolders: false, + date: new Date(), + comment: `RFQ: ${rfqId}` + }); + + addedFiles++; + + } catch (error) { + console.error(`파일 처리 실패: ${file.name}`, error); + errors.push(`파일 읽기 실패: ${file.name}`); + } + } + + // 7. 추가된 파일이 없으면 오류 + if (addedFiles === 0) { + return NextResponse.json( + { + error: '다운로드할 수 있는 파일이 없습니다', + details: errors + }, + { status: 404 } + ); + } + + // 8. ZIP 파일 생성 (압축 레벨 설정) + const zipBuffer = await zip.generateAsync({ + type: 'nodebuffer', + compression: 'DEFLATE', + compressionOptions: { + level: 9 // 최대 압축 + }, + comment: `RFQ ${rfqInfo.rfq_code} 첨부파일`, + platform: 'UNIX' // 파일 권한 보존 + }); + + // 9. 파일명 생성 + const fileName = `RFQ_${rfqInfo.rfq_code}_attachments_${new Date().toISOString().slice(0, 10)}.zip`; + + // 10. 로그 기록 + console.log(`ZIP 생성 완료: ${fileName}, 파일 수: ${addedFiles}/${files.length}, 크기: ${(zipBuffer.length / 1024).toFixed(2)}KB`); + + if (errors.length > 0) { + console.warn('처리 중 오류 발생:', errors); + } + + // 11. 응답 반환 + return new NextResponse(zipBuffer, { + status: 200, + headers: { + 'Content-Type': 'application/zip', + 'Content-Disposition': `attachment; filename="${fileName}"`, + 'Content-Length': zipBuffer.length.toString(), + 'Cache-Control': 'no-cache, no-store, must-revalidate', + 'X-Files-Count': addedFiles.toString(), + 'X-Total-Files': files.length.toString(), + 'X-Errors-Count': errors.length.toString(), + }, + }); + + } catch (error) { + console.error('전체 다운로드 오류:', error); + return NextResponse.json( + { + error: '파일 다운로드 중 오류가 발생했습니다', + details: error instanceof Error ? error.message : 'Unknown error' + }, + { status: 500 } + ); + } +} + +// OPTIONS 요청 처리 (CORS) +export async function OPTIONS(request: NextRequest) { + return new NextResponse(null, { + status: 200, + headers: { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Methods': 'POST, OPTIONS', + 'Access-Control-Allow-Headers': 'Content-Type', + }, + }); +}
\ No newline at end of file |
