Angular keeps redirecting me to the login page even though I'm trying to access another page

后端 未结 1 1369
我寻月下人不归
我寻月下人不归 2020-12-12 07:22

I have a website that it is divided into a normal pages that can be accessed by the user and another page that it is only accessible by admins(which is the ngx-admin).

相关标签:
1条回答
  • 2020-12-12 07:41

    You have a redirect to users on error of the routing.

       { path: '**', pathMatch: 'full', redirectTo: 'users'},
    

    So every time you go to a wrong path it would redirect to:

    { path: 'users', loadChildren: 'app/pages/pages.module#PagesModule', canActivate: [AuthGuard]}
    

    I would consider adding a page with route as default and when a route does not match redirect to that page:

    { path: '', component: HomeComponent},
    { path: '**', pathMatch: 'full', redirectTo: ''},
    

    Another thing to note check if you really need the useHash. This is necesary for some environments only.

    0 讨论(0)
提交回复
热议问题