react 跨域请求设置代理(proxy)转换请求,原因是访问限制同源服务器跨域需要做跨域允许(至于这个限制是浏览器限制还是服务器?)
一、对于Taro项目编辑根目录下的 config/dev.js 文件
h5: {
devServer: {
host: 'localhost',
port: 10086,
proxy: {
'/propertypay/customer/': {
target: 'http://localhost:8880/', // 服务端域名
changeOrigin: true
}
}
},
}
二、antd项目在config\config.ts配置文件
proxy: {
'/propertypay/manage': {
target: 'http://localhost:8080/propertypay/manage',
pathRewrite: { '^/propertypay/manage': '' },
changeOrigin: true
},
}