在根目錄下建立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/, '')
}
}
}