Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular service worker not register in development mode

I would like to know if it' s possible to test pwa and register the serviceworker during the dev mode ( not production)

As when i make the ng build --prod then launchhttp-server in the dist folder it works fine, but then when i do ng serve without the build it gives me the chrome error: Service Worker failed to register

Are the procedures same on prod and dev ? as with lighthouse, the audit gives me ok on serviceworker on prod but not in dev for the same project

Any helps or links would be appreciate

Thanks

like image 964
dtjmsy Avatar asked Feb 04 '18 14:02

dtjmsy


1 Answers

This question is 2 years old but I see it wasn't answered.

You cannot run service worker with ng server. As you mentioned, it works using http-server. This is by design. See Angular documentation here.

However, if you are not testing specific service worker functionality, such as retrieving data from cache if offline, your application will still function using ng serve, including retrieving data via http.

like image 66
DevReboot Avatar answered Oct 12 '22 09:10

DevReboot