diff --git a/docker-compose.yml b/docker-compose.yml index 74763e7..7ff156f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,8 +20,9 @@ services: context: ./backend dockerfile: Dockerfile container_name: line-of-sight-backend - ports: - - "3051:3051" + # Removed public port exposure for security; accessible via frontend proxy + # ports: + # - "3051:3051" environment: - DATABASE_URL=postgresql://line_of_sight:line_of_sight_pass@postgres:5432/line_of_sight - PORT=3051 @@ -40,7 +41,7 @@ services: ports: - "3050:3050" environment: - - VITE_API_URL=http://localhost:3051/api + - VITE_API_URL=/api depends_on: - backend volumes: diff --git a/frontend/src/services/api.js b/frontend/src/services/api.js index f85dba8..6800c49 100644 --- a/frontend/src/services/api.js +++ b/frontend/src/services/api.js @@ -1,6 +1,6 @@ import axios from 'axios'; -const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:3051/api'; +const API_BASE_URL = import.meta.env.VITE_API_URL || '/api'; const api = axios.create({ baseURL: API_BASE_URL, diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 6aa9d0f..c8d6f65 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -12,7 +12,13 @@ export default defineConfig({ server: { port: 3050, host: '0.0.0.0', - allowedHosts: true + allowedHosts: true, + proxy: { + '/api': { + target: 'http://backend:3051', + changeOrigin: true + } + } }, build: { outDir: 'build',