24 lines
645 B
JavaScript
24 lines
645 B
JavaScript
import { defineConfig } from 'vite'
|
|
import uni from '@dcloudio/vite-plugin-uni'
|
|
import path from 'path'
|
|
|
|
// 用来匹配地址,解决跨域问题
|
|
export default defineConfig({
|
|
plugins: [uni()],
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, 'src')
|
|
},
|
|
},
|
|
server: {
|
|
proxy: {
|
|
// 匹配所有 /api 开头的请求
|
|
'/api': {
|
|
target: 'http://localhost:8084', // 你的后端SpringBoot地址
|
|
changeOrigin: true, // 开启跨域伪装
|
|
// rewrite: (path) => path.replace(/^\/areyouok/, '')
|
|
// 举例:前端请求 /api/login → 代理成 http://localhost:8088/login
|
|
}
|
|
}
|
|
}
|
|
}) |