【问题标题】:Passport Authentication Redirection to absolute URL fails护照身份验证重定向到绝对 URL 失败
【发布时间】:2019-01-19 02:00:42
【问题描述】:

我想将请求重定向到另一个 URL,以及通过 passport in express js 登录到 Facebook 时收到的代码/令牌。

app.get('/auth/facebook/callback', function (req, res, next) {
    var authenticator = passport.authenticate('facebook', {
        successRedirect: "http://localhost:3200/#/home/",
        failureRedirect: '/'
    });

问题是它不会重定向到与查询中的代码一起指定的 url,所以我也可以在 Angular 应用程序中管理状态。

【问题讨论】:

    标签: node.js typescript express passport.js passport-facebook


    【解决方案1】:

    您应该使用passport.authenticate 而不是function (req, res, next)

    app.get('/auth/facebook/callback', passport.authenticate('facebook', {
        successRedirect: "http://localhost:3200/#/home/",
        failureRedirect: '/'
    }));
    

    【讨论】:

      猜你喜欢
      • 2016-06-28
      • 2018-11-06
      • 2016-04-03
      • 1970-01-01
      • 2016-10-01
      • 2018-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多