When your microfrontends are lazy-loaded, the route guards should ideally be defined in the shell application where routes for the microfrontends are configured. The key here is to apply the guard on the lazy-loaded route in the shell application, not within the individual microfrontend's routing module.
[
{
path: 'microfrontend1',
loadChildren: () => import('microfrontend1').then(m => m.Microfrontend1Module),
canActivate: [AuthGuard], // Global guard for all microfrontends
},
{
path: 'microfrontend2',
loadChildren: () => import('microfrontend2').then(m => m.Microfrontend2Module),
canActivate: [AuthGuard], // Global guard for all microfrontends
}
]