不能跨域
http://localhost:8080/api/login成为http://localhost:8080/index.html
proxyTable: {
'/api': {
target: 'http://47.106.74.67:8080',
changeOrigin: true,
pathRewrite: {
'^/api': '/'
}
}
},
为什么? 我尝试更改 webpack.dev.conf.js 中的所有 devServer,但我找不到处理 nerwork
最佳答案
以下配置会将您带到http://47.106.74.67:8080/login 对于 http://localhost:8080/api/login .
proxyTable: {
'/api': {
target: 'http://47.106.74.67:8080',
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
}
}
如需转发至http://47.106.74.67:8080/api/login然后删除 pathRewrite
配置。文档@ vue-webpack-proxy和 http-proxy-middleware#options
关于javascript - 我的项目使用代理跨域,但是当我请求它的请求地址改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49963522/