Fix CORS and API URLs for container communication

This commit is contained in:
Zhi
2026-03-14 08:49:12 +00:00
parent b44267aac0
commit 99ca422c3d
3 changed files with 7 additions and 3 deletions

View File

@@ -34,7 +34,8 @@ services:
CONFIG_DIR: /config CONFIG_DIR: /config
LISTEN_ADDR: "0.0.0.0:${WIZARD_PORT:-8080}" LISTEN_ADDR: "0.0.0.0:${WIZARD_PORT:-8080}"
MAX_BACKUPS: "5" MAX_BACKUPS: "5"
CORS_ORIGINS: http://127.0.0.1:${FRONTEND_PORT:-3000},http://localhost:${FRONTEND_PORT:-3000} # Allow frontend (container network) and localhost for testing
CORS_ORIGINS: http://frontend:${FRONTEND_PORT:-3000},http://127.0.0.1:${FRONTEND_PORT:-3000},http://localhost:${FRONTEND_PORT:-3000}
ports: ports:
- "127.0.0.1:${WIZARD_PORT:-8080}:${WIZARD_PORT:-8080}" - "127.0.0.1:${WIZARD_PORT:-8080}:${WIZARD_PORT:-8080}"
networks: networks:
@@ -74,7 +75,8 @@ services:
container_name: harborforge-test-frontend container_name: harborforge-test-frontend
restart: "no" restart: "no"
environment: environment:
VITE_API_BASE_URL: http://127.0.0.1:${BACKEND_PORT:-8000} # Use internal service name for backend API
VITE_API_BASE_URL: http://backend:${BACKEND_PORT:-8000}
ports: ports:
- "127.0.0.1:${FRONTEND_PORT:-3000}:${FRONTEND_PORT:-3000}" - "127.0.0.1:${FRONTEND_PORT:-3000}:${FRONTEND_PORT:-3000}"
depends_on: depends_on:

View File

@@ -32,6 +32,7 @@ services:
CONFIG_DIR: /config CONFIG_DIR: /config
LISTEN_ADDR: "0.0.0.0:${WIZARD_PORT:-8080}" LISTEN_ADDR: "0.0.0.0:${WIZARD_PORT:-8080}"
MAX_BACKUPS: "5" MAX_BACKUPS: "5"
# Internal network only
CORS_ORIGINS: http://frontend:${FRONTEND_PORT:-3000} CORS_ORIGINS: http://frontend:${FRONTEND_PORT:-3000}
ports: ports:
- "127.0.0.1:${WIZARD_PORT:-8080}:${WIZARD_PORT:-8080}" - "127.0.0.1:${WIZARD_PORT:-8080}:${WIZARD_PORT:-8080}"
@@ -67,6 +68,7 @@ services:
container_name: harborforge-test-frontend container_name: harborforge-test-frontend
restart: "no" restart: "no"
environment: environment:
# Use internal service name
VITE_API_BASE_URL: http://backend:${BACKEND_PORT:-8000} VITE_API_BASE_URL: http://backend:${BACKEND_PORT:-8000}
networks: networks:
- test-network - test-network