Next.js Discord

Discord Forum

redirecting the user to their new dashboard url

Answered
Cape lion posted this in #help-forum
Open in Discord
Cape lionOP
I have a feature where the user gets to change their dashboard url

1. before the user is at /${teamslug}/dashboard

2. they cahnge their username - the database is updated

3. we pushstate to /${newTeamslug}/dashboard

4. ERROR 404 (see screeshot)

5. i manually type in the new url and it works

Ive tried all kinds of things, including
- router.reload()
- router.pushState
- router.replace
- waiting a second before pushing the state

But kind of lost here, any advice would be very helpful
Answered by Cape lion
      session.update()
      router.push(newUrl, undefined, { shallow: false });

update teh session first
View full answer

2 Replies

Cape lionOP
my guess is the teamslug isn't changed somewhere where it's looking? where is it looking?
Cape lionOP
      session.update()
      router.push(newUrl, undefined, { shallow: false });

update teh session first
Answer