The Aurelia router remembers which page I was last on, even after using setRoot() and it will redirect me to that page, even though I would want to land on the main app page again.
I'll try to explain it in a usecase.
I have two apps: login
and app
.
I login in login
app and get redirected to app
.
I navigate to /securedPage
on app
and then proceed to log out and get redirected to login
again.
I login with another user on login
and then I get redirected to app/securedPage
.
I want to be and should be redirected to just app
.
How do I clear the route history when switching between apps with setRoot()?
Wanted to help out, recently got this working and the suggestions above almost work, but they are missing some parts. In this thread, the creator of Aurelia (Eisenberg) repsonds with a suggestion: https://github.com/aurelia/framework/issues/590
So to switch app root do the following:
In my case I could actually skip the reset and deactivate part and just do
However doing this.router.navigate('/') without the replace and trigger part caused problems especially when switching app root multiple times.
So make sure to add:
It is not pretty but this this did the trick for me:
did you try