When I click on the navigation link with code for button click, it works perfectly fine:
this.router.navigate(['/dashboard', this.selectedDateString]);
However, if I manually type the URL into the address bar like this:
I receive a
forbidden!
message. Why does routing work when triggered from within the app but not when directly typed into the address bar?This is my routing module setup:
const appRoutes: Routes = [
{ path: 'dashboard/:date', component: DashboardComponent },
{ path: 'dashboard', component: DashboardComponent },
{ path: '', redirectTo: '/dashboard', pathMatch: 'full' },
{ path: '**', component: PageNotFoundComponent }
];
@NgModule({
imports: [
RouterModule.forRoot(
appRoutes, { onSameUrlNavigation: 'reload' }
)
],
exports: [
RouterModule
]
})
export class AppRoutingModule {}