与标题状态一样,我无法理解为什么我的res.redirect不会将原始数据重定向到其引用服务。
Backend现在在Node.js,Express上。
有一点需要注意的是,机构正在与Postman合作,但当我通过我的客户端(浏览器)拨打电话时,它无法正常工作。
总体方案如下: 服务器1 1."客户提出POST请求" 2."后端接收POST请求" /"后端重定向POST请求"
服务器2 3."重定向请求进入路由" 4."使用bodyParser()打开body" 5." req.body"财产完全是空的...... :(
这是我在Server1上的代码: '客户':
// note that `brian` and `google` are route parameters
axios.post(`/apicall/brian/google, {
urls: ['http://www.facebook.com']
})
.then((resp) => {
const data = resp.data;
// etc.
})
'服务器1':
app.route(`/apicall/:user/:domain`)
.post((req, res) => {
const {user, domain} = req.params;
// the req.body property is still filled here
res.redirect(307, `http://127.0.0.1:3000/apicall/${user}/${domain});
});
这是我在server2上的代码: '服务器2':
app.route(`/apicall/:user/:domain`)
.post((req, res) => {
const {user, domain} = req.params;
const {urls} = req.body; // NOTHING ON THE BODY HERE. :(
res.send(...);
});
谢谢!