Mic*_*bry 32 routes node.js express
我有一个使用node.js和braintree的支付系统,当支付成功时,我想将用户发送到后端.我的后端设置在其他地方.
我试过了
res.writeHead(301,
{Location: 'http://app.example.io'}
);
res.end();
Run Code Online (Sandbox Code Playgroud)
所以window.location显然不可用.我想不出任何重定向用户的方法?
The*_*per 88
你可以做
res.redirect('https://app.example.io');
Run Code Online (Sandbox Code Playgroud)
快递文档:https://expressjs.com/en/api.html#res.redirect
选定的答案对我不起作用.它将我重定向到:locahost:8080/www.google.com- 这是无稽之谈.
301 Moved Permanently需要包括在内,res.status(301)如下所示.
app.get("/where", (req, res) => {
res.status(301).redirect("https://www.google.com")
})
Run Code Online (Sandbox Code Playgroud)
由于你的后端在其他地方,你处于相同的情况.
小智 5
app.get("/where", (req, res) => {
res.status(301).redirect("https://www.google.com")
})
Run Code Online (Sandbox Code Playgroud)
您需要包括状态(301)
| 归档时间: |
|
| 查看次数: |
55526 次 |
| 最近记录: |