I have an issue, using AuthGuard on routes. After successful login, when I try to navigate to the path protected with AuthGuard, it redirects me to the root url, like for example: http://localhost:7200.
I have noticed, when I try to access the AuthGuard route, on Network I see a request with name token
and status code 401 Unauthorized.
Please have in mind that am using a Regular Web Application service on my auth0 account for this angular project and I have provided the correct clientId as long as the domain.
I have initialized the auth0-angular like below:
Inside app.module I added:
AuthModule.forRoot({ domain: [domain], clientId: '[clientId]', authorizationParams: { redirect_uri:
${window.location.origin}, }, }),
On app-routing.module.ts
` import { DashboardComponent } from ‘./modules/dashboard/dashboard.component’;
import { AuthGuard } from ‘@auth0/auth0-angular’;
const routes: Routes = [
{
path: 'dashboard',
component:DashboardComponent,
canActivate: [AuthGuard],
},
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule],
})
export class AppRoutingModule {}`
Reproduction
Step 1: Iinitialize a Regular Web Application On auth0.com
Step 2: Copy the code above
Step 3: And test it
Additional context
No response
auth0-angular version
2.2.1
Angular version
16.2.9
Which browsers have you tested in?
Chrome