Need Multiple direct entry point urls application in Angular 10 +

27 Views Asked by At

What i want to Achieve

  1. When user enters on anything on the browser it should take them to LogComponent
  2. When user enters "/info" it should directly take em to info page.

I have inherited a code which is built on Angular 10. Till now i had only one entry point which is the login page. So even if users dont enter "/login" in their browser, by default it used to take them to login page. all the other pages were protected. Below is my routing module.

export const routes: Routes =[
{path:'', component: LogComponent},
{path:'/dashboard', component: DashboardComponent, canActivate[AuthGate]},
...
...
{path:'**', component: LogComponent},
];

What I want to do:

I want to add another page called which can be accessed when users click "/info".

What I did:

So I mimicked the LogComponent Url which does not have canActivate method.. Below is how i added it.

export const routes: Routes =[
{path:'', component: LogComponent},
{path:'/info', component: InfoComponent},
{path:'/dashboard', component: DashboardComponent, canActivate[AuthGate]},
...
...
{path:'**', component: LogComponent},
];

What is happening:

The problem i am facing is , even when users click on /info it goes to info page and redirects back to login page. It is not taking them to InfoComponent which i want

0

There are 0 best solutions below