Deployed app returns 404 instead redirect to specified component

Discussão em 'Angular' iniciado por pawurb, Abril 1, 2025.

  1. pawurb

    pawurb Guest

    I have configured my Angular 19 routes according to the angular.dev and it works as expected on localhost. However once I build and deploy my app behaviour of redirecting with wildcard is not working anymore.

    Once app is on localhost:4200 I can give it any not existing route like localhost:4200/abcdef and it will immediately redirect to /user. But after I deploy the app on server and type not existing route, default 404 page is displayed (instead of redirect).

    Here is my setup from

    app.routes.ts:

    export const routes: Routes = [
    { path: 'user', component: UserComponent },
    { ... other components ...},
    { path: '', redirectTo: '/user', pathMatch:'full'},
    { path: '**', redirectTo: '/user', pathMatch:'full'}
    ];


    I tried reordering of routes but that didn't solve the issue. I tried creating PageCotFoundComponent but this is not what I want longterm. I checked HAshLocationStrategy but this is not what I want longterm.

    Continue reading...

Compartilhe esta Página