gpt4 book ai didi

javascript - 我的项目使用代理跨域,但是当我请求它的请求地址改变

转载 作者:行者123 更新时间:2023-11-30 20:34:41 25 4
gpt4 key购买 nike

不能跨域

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-proxyhttp-proxy-middleware#options

关于javascript - 我的项目使用代理跨域,但是当我请求它的请求地址改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49963522/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com