Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refreshing a route while offline fails (angular service worker) #9558

Closed
maa105 opened this issue Feb 8, 2018 · 3 comments
Closed

Refreshing a route while offline fails (angular service worker) #9558

maa105 opened this issue Feb 8, 2018 · 3 comments

Comments

@maa105
Copy link

maa105 commented Feb 8, 2018

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 does not have caching rules.

@maa105
Copy link
Author

maa105 commented Feb 8, 2018

workaround for now use hash routing instead of path routing (https://angular.io/guide/router#browser-url-styles)

@Brocco
Copy link
Contributor

Brocco commented Feb 8, 2018

This issue is related to service worker in the main repository and not an issue in the CLI. Please create an issue in the main repo here and include a reproduction of the issue.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants