diff --git a/backend-node/src/app.ts b/backend-node/src/app.ts index 53a00c0b..3b567a0a 100644 --- a/backend-node/src/app.ts +++ b/backend-node/src/app.ts @@ -30,7 +30,7 @@ app.use(express.urlencoded({ extended: true, limit: "10mb" })); // CORS 설정 app.use( cors({ - origin: config.cors.origin, + origin: config.cors.origin.split(",").map((url) => url.trim()), credentials: true, methods: ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"], allowedHeaders: ["Content-Type", "Authorization", "X-Requested-With"], @@ -86,11 +86,13 @@ app.use(errorHandler); // 서버 시작 const PORT = config.port; +const HOST = config.host; -app.listen(PORT, () => { - logger.info(`🚀 Server is running on port ${PORT}`); +app.listen(PORT, HOST, () => { + logger.info(`🚀 Server is running on ${HOST}:${PORT}`); logger.info(`📊 Environment: ${config.nodeEnv}`); - logger.info(`🔗 Health check: http://localhost:${PORT}/health`); + logger.info(`🔗 Health check: http://${HOST}:${PORT}/health`); + logger.info(`🌐 External access: http://39.117.244.52:${PORT}/health`); }); export default app; diff --git a/backend-node/src/config/environment.ts b/backend-node/src/config/environment.ts index be936f76..56478ae3 100644 --- a/backend-node/src/config/environment.ts +++ b/backend-node/src/config/environment.ts @@ -82,8 +82,8 @@ const config: Config = { // CORS 설정 cors: { - origin: process.env.CORS_ORIGIN || "http://localhost:9771", - credentials: process.env.CORS_CREDENTIALS === "true", + origin: process.env.CORS_ORIGIN || "http://localhost:9771,http://192.168.0.70:5555,http://39.117.244.52:5555", + credentials: process.env.CORS_CREDENTIALS === "true" || true, }, // 로깅 설정 diff --git a/docker/prod/docker-compose.backend.prod.yml b/docker/prod/docker-compose.backend.prod.yml index cd29965c..3cded048 100644 --- a/docker/prod/docker-compose.backend.prod.yml +++ b/docker/prod/docker-compose.backend.prod.yml @@ -5,20 +5,17 @@ services: context: ../../backend-node dockerfile: ../docker/prod/backend.Dockerfile # 운영용 Dockerfile container_name: pms-backend-prod - ports: - - "8080:8080" + network_mode: "host" # 호스트 네트워크 모드 environment: - NODE_ENV=production - PORT=8080 + - HOST=0.0.0.0 # 모든 인터페이스에서 바인딩 - DATABASE_URL=postgresql://postgres:ph0909!!@39.117.244.52:11132/plm - JWT_SECRET=ilshin-plm-super-secret-jwt-key-2024 - JWT_EXPIRES_IN=24h - - CORS_ORIGIN=http://192.168.0.70:5555 + - CORS_ORIGIN=http://192.168.0.70:5555,http://39.117.244.52:5555 - CORS_CREDENTIALS=true - LOG_LEVEL=info - # 운영용에서는 볼륨 마운트 없음 (보안상 이유) - networks: - - pms-network restart: unless-stopped healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8080/health"] diff --git a/frontend/lib/api/client.ts b/frontend/lib/api/client.ts index e3eef389..659a512a 100644 --- a/frontend/lib/api/client.ts +++ b/frontend/lib/api/client.ts @@ -1,7 +1,6 @@ import axios, { AxiosResponse, AxiosError } from "axios"; -// API 기본 URL 설정 -export const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || "http://localhost:8080/api"; +export const API_BASE_URL = "http://39.117.244.52:8080/api"; // JWT 토큰 관리 유틸리티 const TokenManager = { diff --git a/frontend/next.config.mjs b/frontend/next.config.mjs index 286faf4a..50f2755d 100644 --- a/frontend/next.config.mjs +++ b/frontend/next.config.mjs @@ -41,9 +41,9 @@ const nextConfig = { ]; }, - // 환경 변수 (런타임에 읽기) + // 환경 변수 (런타임에 읽기) - 내부 IP로 통일 env: { - NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL || "http://192.168.0.70:8080/api", + NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL || "http://39.117.244.52:8080/api", }, };