在快递中,我如何将用户重定向到外部网址? [英] In express how do I redirect a user to an external url?

查看:17
本文介绍了在快递中,我如何将用户重定向到外部网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 node.js 和 Braintree 的支付系统,当支付成功时,我想将用户发送到后端.我的后端设置在其他地方.

I have a payment system using node.js and braintree, when the payment is successful I want to send the user to the back end. My back end is setup elsewhere.

我试过了

res.writeHead(301,
  {Location: 'http://app.example.io'}
);
res.end();

所以 window.location 显然不可用.我想不出任何方法来重定向用户?

So window.location is obviously not available. I cant think of any ways to redirect a user?

推荐答案

你可以做

res.redirect('https://app.example.io');

Express 文档:https://expressjs.com/en/api.html#res.redirect

Express docs: https://expressjs.com/en/api.html#res.redirect

这篇关于在快递中,我如何将用户重定向到外部网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆