I have a simple app with routing functionality which has a redirection:
const routes: Routes = [
{
path: '',
redirectTo: 'orders',
pathMatch: 'full'
},
{
path: 'orders',
component: OrdersComponent
},
];
The <router-outlet></router-outlet>
tag just lies inside the root template (of app.component.ts
).
Next, I add the Angular PWA functionality
ng add @angular/pwa
and build my app for production
ng build
When I for the first time open my app through a http server visiting the /
path and being redirected to /orders
I see this error in dev tools:
Failed to load resource: the server responded with a status of 404 (Not Found) - /orders
The application itself operates smoothly.
It seems that a service worker, which starts its work after the redirection is fulfilled, tries to cache the current page making a request to the current url (/orders
) instead of using the root path (/
).
Where does this error come from and how can I tell the PWA functionality not to use redirected paths for requests to the server?