[SOLVED] Redirecting after login using FlowRouter

I tried to do a redirect after a successful login. The redirectAfterLogin is set correctly and FlowRouter.go(redirect); will be executed. Bu instead of showing the right page the route will stuck on “/”.

Accounts.onLogin(function () {
    let redirect = Session.get("redirectAfterLogin");
    if(redirect) {
        Session.set("redirectAfterLogin", null);
        FlowRouter.go(redirect);
    } else {
        FlowRouter.go("/");
    }
});

Meteor.setTimeout(function() {FlowRouter.go(redirect)}, 100); did the trick

You can use Meteor.defer instead of Meteor.setTimeout

1 Like