vue项目,本地启动时,请求地址会自动加上http://localhost:
wepack设置时,使用代理
devServer: {
hot: true,
host: '0.0.0.0',
port: "2023", // 项目启动端口, 默认8080
//https: true, // 是否开启https 默认false
// 代理设置
proxy: {
"/apl": {
target: "127.0.0.1:3007",
changeOrigin: true,
pathRewrite: {
"^/apl": ""
},
// 解决本地请求https问题
// secure: false,
// headers: {
// Referer: "https://www.qzyxs.com"
// }
}
}
},
代理中的target参数未加协议名,默认相对地址,所以会自动在前面加上本地地址,http://localhost:加上 https:// 就可以了
devServer: {
hot: true,
host: '0.0.0.0',
port: "2023", // 项目启动端口, 默认8080
//https: true, // 是否开启https 默认false
// 代理设置
proxy: {
"/apl": {
target: "https://127.0.0.1:3007",
changeOrigin: true,
pathRewrite: {
"^/apl": ""
},
// 解决本地请求https问题
// secure: false,
// headers: {
// Referer: "https://www.qzyxs.com"
// }
}
}
},

浙公网安备 33010602011771号