OL-LearnPlatform-Frontend/vite.config.ts
2025-08-11 10:03:56 +08:00

37 lines
947 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 { fileURLToPath, URL } from 'node:url'
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
// https://vite.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
const proxyTarget = env.VITE_PROXY_TARGET || 'http://110.42.96.65:55510'
return {
plugins: [
vue(),
vueDevTools(),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
},
},
server: {
port: 3000,
open: true,
proxy: {
// 将以 /api 开头的请求代理到后端避免浏览器CORS限制
'/api': {
target: proxyTarget,
changeOrigin: true,
// 如果后端接口不是以 /api 开头,可在这里改写路径
// rewrite: (path) => path.replace(/^\/api/, '')
}
}
}
}
})