Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next router.Push("/dashboard") is not working with nested path instead of root "/" #573

Open
ABIDULLAH786 opened this issue May 22, 2023 · 0 comments

Comments

@ABIDULLAH786
Copy link

i want to use the nookies to set the cookies when the user response is get from server and based on response. and after that i am want to redirect the user to "/dasboard" .
It saves the cookies to the specific path but unable to redirect the user to mentioned route.
here is the code

`
const saveUserDetails = async () => {
// ... your login logic

  if (user.data.role === 'USER') {
    const expiryTime = new Date(new Date().getTime() + 360 * 60 * 1000);

    setCookie('role', user?.data?.role, {
      expires: expiryTime,
      path: '/dashboard/user',
    });

    setCookie('user', JSON.stringify(user?.data?.userLogged), {
      expires: expiryTime,
      path: '/dashboard/user',
    });

    router.push('/dashboard/user');
    SimpleAlert('Success', 'Successfully logged in', 'success');
  }
};

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant