I've been having issues with a guard loop and I'm trying to find out the best routing setup.
Current routing structure...
Root path with a guard on it.
A child dashboard route with a resolver that requires a route param.
A child session route for login sign out etc.
A child error route.
Problems I have...
As part of app initialisation I redirect to sign in. This then triggers the guard which then returns false as user isn't authenticated which then means sign in route isn't activated.
When they're signed in they're navigated back to the root path. Which then kicks off the guard. Problem then becomes that the guard redirects to a child dashboard route. But then gets stuck in a loop because the redirect is to a child of the root the guard is on.
Same issue as 2 but for when an error occurs in guard and try to redirect there
I just can't work out what the correct routing, guard structure should be?
https://angular.io/api/router/CanActivateFn
Then your routes definition should have guarded routes and others that are not. Otherwise, you will be stuck in a loop