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

Service worker not getting registered in localhost #82

Closed
vaibhavarora14 opened this issue Oct 28, 2020 · 7 comments
Closed

Service worker not getting registered in localhost #82

vaibhavarora14 opened this issue Oct 28, 2020 · 7 comments

Comments

@vaibhavarora14
Copy link

Description

For localhost, service worker is not getting registered

Steps to reproduce

It's easy to reproduce in all apps versioning 1.0.2 of this template.

Expected behavior
Service worker should get registered

Screenshots
Reason - For production it should work as per code. For localhost we are checking for service-worker.js file on window.origin. Which doesn't exist because there is no such file exposed in build folder when build is made.

image
image

I wish I could run other typescript templates and see the difference.

Versions

  • react-boilerplate-cra-template: 1.0.2
  • Node/NPM: 12.18.4/6.14.8
  • Browser: Chrome 86.0.4240.111 (Official Build) (64-bit)
@Can-Sahin
Copy link
Member

Did you register the service worker here =>

serviceWorker.unregister();

@vaibhavarora14
Copy link
Author

yes I did, that's how I am able to add captured screenshot of live debugging

@Can-Sahin
Copy link
Member

I don't understand exactly. Can you do what you want with CRA and show me what output this boilerplate can't produce where in fact CRA can?

@vaibhavarora14
Copy link
Author

https://github.com/varora1406/example-app

I have enabled service worker as you mentioned, you can run PWA test from google chrome devtools to verify that service worker isn't registered despite the code change you mentioned

Note: checkout latest commit of main branch

@vaibhavarora14
Copy link
Author

Reason is mentioned in facebook/create-react-app#10032

@Can-Sahin
Copy link
Member

I see. I honestly don't know :( It's been so long I didn't test offline-first functionality. In fact, I just removed it from this project because it's not easy to test and I cannot guarantee a working example

@vaibhavarora14
Copy link
Author

vaibhavarora14 commented Jan 19, 2021

i have fixed it in my app
I will submit a PR today here, don't worry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants