Skip to content

router.push doesn't work in production #51782

Answered by bartekczyz
itzAymvn asked this question in Help
Discussion options

You must be logged in to vote

@itzAymvn I don't know why exactly, but in my case it wouldn't redirect because at the time redirecting, router was not aware of user being successfully authenticated, so I had to refresh the state manually

router.refresh()

and then

router.replace('route-to-redirect')

So in your case it would be

    console.log("Before redirect");
    router.refresh(); // dirty fix, but it works
    router.push("/dashboard");
    console.log("After redirect");

CC @icyJoseph

Replies: 7 comments 19 replies

Comment options

You must be logged in to vote
1 reply
@itzAymvn
Comment options

Comment options

You must be logged in to vote
9 replies
@itzAymvn
Comment options

@icyJoseph
Comment options

@itzAymvn
Comment options

@itzAymvn
Comment options

@bartekczyz
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
8 replies
@saman2007
Comment options

@devMiguelCarrero
Comment options

@nicolasheady
Comment options

@CaioMS2000
Comment options

@jamesopti
Comment options

Answer selected by itzAymvn
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Reynalroddy
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet