29 lines
864 B
JavaScript
29 lines
864 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, '.')
|
|
},
|
|
},
|
|
server: {
|
|
proxy: {
|
|
// 匹配所有 /api/ 开头的请求(排除静态文件)
|
|
'/api': {
|
|
target: 'http://192.168.5.15:8084', // 你的后端SpringBoot地址
|
|
changeOrigin: true, // 开启跨域伪装
|
|
// 只代理真正的后端API请求,排除 .js .vue 等静态文件
|
|
bypass: function(req, res, proxyOptions) {
|
|
if (req.url.indexOf('.js') !== -1 || req.url.indexOf('.vue') !== -1 ||
|
|
req.url.indexOf('.css') !== -1 || req.url.indexOf('.json') !== -1) {
|
|
return req.url
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}) |