import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: {
port: 3000,
host: '0.0.0.0',
open: true, //服务器运行后自动打开网页
proxy: {
// 代理配置
'/srv': {
target: 'http://localhost:8000/bus',
changeOrigin: true,//允许跨域
// secure:false,//解决自签名证书错误
rewrite: (path) => path.replace(/^\/srv/, ''),
},
},
}
})
vue3项目中vite.config.ts作用等同于vue.config.js,解决跨域
于 2023-05-05 23:21:23 首次发布