VUE 本地代理开启后 请求地址 301 重定向问题
最近在项目开发中启用本地代理后,发现自己明明写的是POST 请求结果却变成了 GET, 在网上找了好多资料,没有一个可以解决的。 最后求助公司大神,发现请求被重定向了(301),估计是请求地址是 https 的 而本地是 http 的。 最后在 devServer 中 增加了 https: true 配置解决了问题。devServer: {port: port,open: t...
·
最近在项目开发中启用本地代理后,发现自己明明写的是POST 请求结果却变成了 GET, 在网上找了好多资料,没有一个可以解决的。 最后求助公司大神,发现请求被重定向了(301),估计是请求地址是 https 的 而本地是 http 的。 最后在 devServer 中 增加了 https: true
配置解决了问题。
devServer: {
port: port,
open: true,
https: true,
overlay: {
warnings: false,
errors: true
},
proxy: {
'^/api': {
target: `https://xxxxxxxxxxxxx`,
changeOrigin: true,
ws: true,
logLevel: 'debug',
pathRewrite: {
'^/api': ''
}
}
}
}
更多推荐
已为社区贡献2条内容
所有评论(0)