angularroutesangular-routingangular-auxiliary-routes

Angular auxiliary routes works locally but not when deployed


I have a problem with direct access to a Auxiliary route. When I am accessing /home/(post:12) locally everything work just fine. But when I am trying to do it when app is deployed to github pages, wild 404 appears.

Basically the auxiliary route is loading popup modal.

<router-outlet name="post"></router-outlet>

Here is Router Module:

RouterModule.forRoot([
      {
        path: 'home',
        component: ShellComponent,
        children: [
          {
            path: ':postId',
            component: PostEntryComponent,
            outlet: 'post'
          },
          {
            path: '',
            redirectTo: 'home',
            pathMatch: 'full'
          }
        ]
      },
      {path: '**', redirectTo: 'home'}
    ])

I want to make it work like on local server. Any ideas?


Solution

  • Would that help?

    // Excerpt app-routing.module.ts
    
    @NgModule({
      imports: [
        RouterModule.forRoot(routes, {
          useHash: true,
        }),
      ],
      exports: [RouterModule],
    })