瀏覽代碼

Fixed hardcoded ports in frontend

svalavuo 2 天之前
父節點
當前提交
515f9f34a6
共有 4 個文件被更改,包括 4 次插入4 次删除
  1. 1 1
      docker-compose.prod.yml
  2. 1 1
      docker-compose.yml
  3. 1 1
      frontend/src/api/axios.js
  4. 1 1
      frontend/vite.config.js

+ 1 - 1
docker-compose.prod.yml

@@ -42,7 +42,7 @@ services:
       context: ./frontend
       dockerfile: Dockerfile
       args:
-        - VUE_APP_API_URL=${VUE_APP_API_URL:-http://localhost:${BACKEND_PORT:-8080}}
+        - VUE_APP_API_URL=${VUE_APP_API_URL:-http://localhost:9123}
     container_name: inventory-frontend-prod
     ports:
       - "${FRONTEND_PORT:-3000}:80"

+ 1 - 1
docker-compose.yml

@@ -47,7 +47,7 @@ services:
     ports:
       - "${FRONTEND_PORT:-3000}:80"
     environment:
-      - VUE_APP_API_URL=${VUE_APP_API_URL:-http://localhost:${BACKEND_PORT:-8080}}
+      - VUE_APP_API_URL=${VUE_APP_API_URL:-http://localhost:9123}
     depends_on:
       backend:
         condition: service_healthy

+ 1 - 1
frontend/src/api/axios.js

@@ -2,7 +2,7 @@ import axios from 'axios'
 
 // Create axios instance with base URL
 const api = axios.create({
-  baseURL: 'http://localhost:8080',
+  baseURL: import.meta.env.VUE_APP_API_URL || 'http://localhost:8080',
   timeout: 10000,
   headers: {
     'Content-Type': 'application/json'

+ 1 - 1
frontend/vite.config.js

@@ -7,7 +7,7 @@ export default defineConfig({
     port: 3000,
     proxy: {
       '/api': {
-        target: 'http://localhost:8080',
+        target: process.env.VUE_APP_API_URL?.replace(/\/$/, '') || 'http://localhost:8080',
         changeOrigin: true,
         rewrite: (path) => path.replace(/^\/api/, '')
       }