52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
import { defineConfig, loadEnv } from 'vite'
|
||
import vue from '@vitejs/plugin-vue'
|
||
import { fileURLToPath, URL } from 'node:url'
|
||
|
||
|
||
|
||
// https://vite.dev/config/
|
||
export default defineConfig(({ mode }) => {
|
||
const env = loadEnv(mode, process.cwd(), '')
|
||
const apiBaseURL = env.VITE_API_BASE_URL || 'https://token.opencomputing.cn'
|
||
|
||
return {
|
||
plugins: [vue(),],
|
||
resolve: {
|
||
alias: {
|
||
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||
}
|
||
},
|
||
server: {
|
||
host: '0.0.0.0',
|
||
port: 5173,
|
||
// 配置代理解决跨域问题
|
||
proxy: {
|
||
'/api': {
|
||
target: apiBaseURL,
|
||
changeOrigin: true,
|
||
rewrite: (path) => path.replace(/^\/api/, ''),
|
||
},
|
||
'/token':{
|
||
target: apiBaseURL,
|
||
changeOrigin: true,
|
||
rewrite: (path) => path.replace(/^\/token/, ''),
|
||
|
||
},
|
||
// 新增:元境 /v1 接口代理(auth/user 等)
|
||
'/v1': {
|
||
target: apiBaseURL,
|
||
changeOrigin: true,
|
||
},
|
||
// 兼容旧的 /rbac 接口(图片/视频生成)
|
||
'/rbac': {
|
||
target: apiBaseURL,
|
||
changeOrigin: true,
|
||
},
|
||
}
|
||
},
|
||
// optimizeDeps: {
|
||
// exclude: ['@techui/scifi']
|
||
// },
|
||
}
|
||
})
|