How to run service worker locally with Angular

Discussão em 'Angular' iniciado por Yuvals, Fevereiro 11, 2025.

  1. Yuvals

    Yuvals Guest

    I am following angular's best practice in order to make PWA. After making production build (ng build --prod --aot), I am also running the service worker from dist, on localhost: http-server -p 8080 -c-1 dist When I am trying to sync the worker with my Angular, using:

    navigator.serviceWorker.ready.then(function(swRegistration) {

    console.log('swReady');
    });


    Nothing happens, and seems that SW is not communicating with Angular. Working with a remote server (uploading dist) does work. So seems that the problem is dist not working with ng serve. What am I doing wrong?

    Continue reading...

Compartilhe esta Página