0

I would like to know for multi tenant purpose what is the way to set path like localhost:4200\#\company\auth\login or localhost:4200\company\auth\login , where company is a any string parameter and when entering the login page take the company name to go to find the id from the backend or go to some any 404 page when the company is not set on the url or it isn't exists.

Thank you very much!!

1 Answers1

0
  1. Update your app-routing.module to tell router about a global company route param:
const routes: Routes = [

  {
    path: ':company',
    children: [
      { path: 'pages', loadChildren: 'app/pages/pages.module#PagesModule' },
      {
        path: 'auth',

        // ... auth routes
      },
    ],
  },
];
  1. Then somewhere down your code, for example in auth components you can get the parameneter and then work with it:
constructor(private route: ActivatedRoute) {
  this.route.params.subscribe((params: any) => {
    console.log(params.company);
  });
}
  • Hi, thank you very much but now I have another problem with this solution, when I put the company I get this response http://localhost:4200/flycompany/pages/runtime.js net::ERR_ABORTED 404 (Not Found) favicon.ico:1 GET http://localhost:4200/flycompany/pages/favicon.ico 404 (Not Found) favicon.png:1 GET http://localhost:4200/flycompany/pages/favicon.png – Michael Zapata Mar 18 '19 at 19:53