修復api重複
This commit is contained in:
@@ -75,7 +75,7 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- backend
|
||||||
environment:
|
environment:
|
||||||
VITE_API_BASE_URL: /api
|
VITE_API_BASE_URL: ''
|
||||||
VITE_API_URL: http://backend:3001
|
VITE_API_URL: http://backend:3001
|
||||||
ports:
|
ports:
|
||||||
- "2000:3000"
|
- "2000:3000"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ const TOKEN_KEY = 'auth_token';
|
|||||||
|
|
||||||
const http = axios.create({
|
const http = axios.create({
|
||||||
// 🔥 核心修改
|
// 🔥 核心修改
|
||||||
baseURL: '',
|
baseURL: import.meta.env.VITE_API_BASE_URL || '',
|
||||||
timeout: 15000,
|
timeout: 15000,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -4,29 +4,19 @@ import react from '@vitejs/plugin-react';
|
|||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
server: {
|
server: {
|
||||||
host: true,
|
|
||||||
port: 3000,
|
|
||||||
host: '0.0.0.0', // 监听所有网络接口
|
host: '0.0.0.0', // 监听所有网络接口
|
||||||
|
port: 3000,
|
||||||
|
allowedHosts: 'all',
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': {
|
'/api': {
|
||||||
target: process.env.VITE_API_URL || 'http://localhost:33001',
|
target: process.env.VITE_API_URL || 'http://localhost:33001',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
hmr: {
|
|
||||||
host: 'performance-appraisal.excn.top', // 客户端访问的主机名
|
|
||||||
clientPort: 80, // nginx监听80端口,外部代理将HTTPS 443转发到80
|
|
||||||
protocol: 'ws', // WebSocket协议,nginx代理WebSocket
|
|
||||||
},
|
|
||||||
|
|
||||||
allowedHosts: 'all',
|
|
||||||
|
|
||||||
hmr: {
|
hmr: {
|
||||||
host: 'performance-appraisal.excn.top',
|
host: 'performance-appraisal.excn.top',
|
||||||
protocol: 'wss',
|
protocol: 'wss',
|
||||||
clientPort: 443
|
clientPort: 443,
|
||||||
},
|
},
|
||||||
|
|
||||||
// ❌ 直接删掉 proxy(推荐)
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user