在根目錄下新建一個文件夾vue.config.js,注意根目錄是
,而不是src路徑,然后請求
module.exports = {
lintOnSave:false,
devServer: {
overlay:{
warning:false,
errors:false
},
proxy: {
'/api': {
// target: 'http://172.16.15.27:8081',
target: 'http://172.16.15.159:8080/',
secure: false, // false為http訪問,true為https訪問
changeOrigin: true, // 跨域訪問設置,true代表跨域
ws: true,
pathRewrite: { // 路徑改寫規則
'^/api': '' // 以/proxy/為開頭的改寫為''
}
}
}
}
}
