79459313

Date: 2025-02-22 09:16:04
Score: 0.5
Natty:
Report link

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
      }
    ]
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Starts with a question (0.5): When you
  • Low reputation (1):
Posted by: Arpan Gautam