My plan was to set up a project where the main website which is on "/", is quite hefty is only lazy-loaded after actual login.
const routes: Routes = [
{ path: '', canLoad: [AuthGuard], loadChildren: './home/home.module#HomeModule' },
{ path: 'login', component: LoginComponent },
{ path: '**', redirectTo: '/' },
];
But CanLoad seem to have this limitation that it doesn't work for '/' because what happens is that the App get stuck in an infinity loop. CanLoad has a built in auto-redirect to '/' when canLoad is denied, even though you put a redirect to '/login' when "false".
The temporary solution I have is to not use '' root as a route and instead call it '/home' or something, but that will add /home/ in front of every route of the app.
CanActivate guard works with this setup, but then of course I don't get the benefit of lazy loading since the full app (home/) will be loaded anyway, even if the user only is going to get stuck on the /login screen.
Related: