From c48e8716ae8f7a5f5245d3fc6ac667db91049a78 Mon Sep 17 00:00:00 2001 From: zhuyu <990951175@qq.com> Date: Tue, 14 Apr 2026 13:04:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=BE=A9api=E9=87=8D=E8=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 2 +- frontend/src/api/http.ts | 2 +- frontend/vite.config.ts | 16 +++------------- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 715bd7d..cc34e69 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -75,7 +75,7 @@ services: depends_on: - backend environment: - VITE_API_BASE_URL: /api + VITE_API_BASE_URL: '' VITE_API_URL: http://backend:3001 ports: - "2000:3000" diff --git a/frontend/src/api/http.ts b/frontend/src/api/http.ts index 7a28b8a..9759eea 100644 --- a/frontend/src/api/http.ts +++ b/frontend/src/api/http.ts @@ -4,7 +4,7 @@ const TOKEN_KEY = 'auth_token'; const http = axios.create({ // 🔥 核心修改 - baseURL: '', + baseURL: import.meta.env.VITE_API_BASE_URL || '', timeout: 15000, }); diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index c088984..5576d75 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -4,29 +4,19 @@ import react from '@vitejs/plugin-react'; export default defineConfig({ plugins: [react()], server: { - host: true, - port: 3000, host: '0.0.0.0', // 监听所有网络接口 + port: 3000, + allowedHosts: 'all', proxy: { '/api': { target: process.env.VITE_API_URL || 'http://localhost:33001', changeOrigin: true, }, }, - hmr: { - host: 'performance-appraisal.excn.top', // 客户端访问的主机名 - clientPort: 80, // nginx监听80端口,外部代理将HTTPS 443转发到80 - protocol: 'ws', // WebSocket协议,nginx代理WebSocket - }, - - allowedHosts: 'all', - hmr: { host: 'performance-appraisal.excn.top', protocol: 'wss', - clientPort: 443 + clientPort: 443, }, - - // ❌ 直接删掉 proxy(推荐) }, });