Refreshing a route while offline fails (angular service worker) #22110
Labels
area: service-worker
Issues related to the @angular/service-worker package
Milestone
Moved it from angular/angular-cli#9558
Versions:
Windows Server 2008
Angular Version 5.2.4
Angular CLI: 1.6.4
Node: 8.9.1
OS: win32 x64
Angular:
...
Reproduce:
1- Create new angular with service worker and routing (ng new app --service-worker --routing)
2- add a route /home with a link to go to the /home
3- build and deploy
4- open site
5- go to /home page by clicking on the link
6- go offline
7- refresh browser
Observed behavior
when u refresh it fails (cause the URL is /home and /home was not cached but /index.html was)
Desired behavior
since the /home is just the same as /index.html but at a different route it should not fail, the problem won't show if you are offline cause this is handled by the server as in the following script
app.get('*', function (req, res) { res.redirect('/index.html'); });
. so the server knows about it and just return index.html. but the service worker doesn't (it just cached /index.html not /home). I guess my request/question is to be able in the service worker to create a default file for all routes or routes that do not have caching rules.the workaround, for now, use hash routing instead of path routing (https://angular.io/guide/router#browser-url-styles)
The text was updated successfully, but these errors were encountered: