Routing problem: fallback url doesn't work serving the site on a server

I’ve a Ionic6/Angular app with this simple routing defined in app-routing.module.ts:

const routes: Routes = [
    path: '',
    redirectTo: 'student',
    pathMatch: 'full',
    path: 'student',
    loadChildren: () =>
      import('./pages/student/student.module').then((m) => m.StudentPageModule),

I’ve compiled the app with the command:
ionic build
and I’m serving the site with:
http-server .
If I visit the page of the app ( I can see the home page without problems.
But if visit the page: I have a not found error: GET /student" Error (404): "Not found"

Instad, if I run the app locally with “ionic serve” this fallback url works well: http://localhost:8100/student

Which could be the problem according to you?

Thank you very much


It seems it is a problem of the web server configuration and not of the app.
Running the app with:
http-server --proxy http://localhost:8080?

The url works well.



This is because all routes (get requests to server) need to be rewritten by the server to /. Otherwise the router cannot pick it up