Files
KCGL/inventory-web/vite.config.ts
2026-02-04 13:30:07 +08:00

33 lines
955 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { fileURLToPath, URL } from 'node:url'
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: {
// 允许局域网访问前端页面
host: '0.0.0.0',
port: 5173,
proxy: {
// 拦截所有以 /api 开头的请求
'/api': {
// 【关键修改】
// 你的截图显示后端容器名叫 inventory_api
// 在 Docker 内部,直接用这个名字作为域名,就能找到它
target: 'http://inventory_api:8000',
changeOrigin: true,
// 【保持注释】
// 通常 Flask 后端都会把路由写全 (如 /api/v1/auth/login)
// 所以这里不需要 rewrite 去掉 /api直接原样转发过去最稳妥
// rewrite: (path) => path.replace(/^\/api/, '')
}
}
}
})