在根目录下建立vite.config.js.内容设置如下即可
const path = require('path')
module.exports = {
hostname: '0.0.0.0',//允许本机
port: 3000,//设置端口
// 反向代理
proxy: {
'/index.php': {
target: 'http://club.kdslife.com/index.php',
changeOrigin: true,//设置访问目标地址允许跨域
rewrite: path => path.replace(/^\/index/, '')
}
}
}