ForcePilot/web/vite.config.js
Wenjie Zhang 15acdaac73 fix(deploy): 更新API代理配置以匹配容器网络
将nginx和vite配置中的API代理地址统一为容器网络中的地址,确保开发和生产环境的一致性
2025-11-14 11:00:57 +08:00

30 lines
715 B
JavaScript

import { fileURLToPath, URL } from 'node:url'
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
return {
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: {
proxy: {
'^/api': {
target: env.VITE_API_URL || 'http://api:5050',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '/api')
}
},
watch: {
usePolling: true,
ignored: ['**/node_modules/**', '**/dist/**'],
},
host: '0.0.0.0',
}
}
})