0

在 Express 我正在使用:

var router = express.Router();
router.get('/auth/*', function (req, res, next) {
  next();
})
app.use(router);

app.all('/*', function(req, res) {
  res.sendfile('index.html', { root: __dirname + '/app/dist' });
});

在 Angular $routeProvider 中:

when('/auth/:type', {}).

当我使用社交登录到 Meetup/auth/meetup时,它会进行身份验证,但不会重新路由到/profile/meetupsuccessRedirect Passport 中指定的路径:

app.get('/auth/meetup', passport.authenticate('meetup', { scope : 'email' }));

app.get('/auth/meetup/callback',
    passport.authenticate('meetup', {
        successRedirect : '/profile/meetup',
        failureRedirect : '/login'
    }));

当我单击一个按钮时,href="/auth/meetup"我会在地址栏中看到一个带有 url 的空白屏幕:http://localhost:2997/auth/meetup当我刷新页面时,我会自动被路由到,'/profile/meetup'因此身份验证成功。

为什么 Node/Express/Angular 在身份验证后不重定向到 /profile/meetup?

4

1 回答 1

1

您不希望 angularjs 将路由作为 HTML5 样式的单页应用程序路由来处理。您希望浏览器为/auth/meetup. 因此,在您的 HTML<a>标记中添加target="_self"将禁用角度路由器并允许传统超链接工作。

于 2014-09-25T20:38:42.117 回答