/** @type {import('next').NextConfig} */ const nextConfig = { // Docker 빌드 최적화 output: "standalone", // ESLint 빌드 시 무시 (프로덕션 빌드 성공을 위해) eslint: { ignoreDuringBuilds: true, }, // TypeScript 오류도 무시 (필요한 경우) typescript: { ignoreBuildErrors: true, }, // 실험적 기능 활성화 experimental: { outputFileTracingRoot: undefined, }, async rewrites() { // 개발 환경과 운영 환경에 따른 백엔드 URL 설정 const backendUrl = process.env.NODE_ENV === "development" ? "http://localhost:3000" : "http://backend:8080"; return [ { source: "/api/:path*", destination: `${backendUrl}/api/:path*`, }, ]; }, // 개발 환경에서 CORS 처리 async headers() { return [ { source: "/api/:path*", headers: [ { key: "Access-Control-Allow-Origin", value: "*" }, { key: "Access-Control-Allow-Methods", value: "GET,POST,PUT,DELETE,OPTIONS" }, { key: "Access-Control-Allow-Headers", value: "Content-Type, Authorization" }, ], }, ]; }, // 환경 변수 (런타임에 읽기) env: { // 개발 환경에서는 Next.js rewrites를 통해 /api로 프록시 NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL || "/api", }, }; export default nextConfig;