pwa-module icon indicating copy to clipboard operation
pwa-module copied to clipboard

Can't add custom service worker

Open artrayd opened this issue 3 years ago • 5 comments

Doing same as in docs

// nuxt.config.js
pwa: {
  workbox: {
    importScripts: ['custom-sw.js'],
  }
}

// static/custom-sw.js
console.log('Custom service worker!')

And nothing in console..

artrayd avatar Jun 10 '21 05:06 artrayd

Are you testing using the development server yarn dev? If so try with yarn build and then yarn start. As per the docs

shot-codes avatar Jul 05 '21 19:07 shot-codes

Hi @TheFoolishPupil thank you for your answer, I tried to do as you said and there is still no message in console :(

Created also a sample at codesandbox.io. Please tell me what I'm doing wrong :)

https://codesandbox.io/s/youthful-sound-ifdo1?file=/nuxt.config.js

artrayd avatar Aug 02 '21 06:08 artrayd

nuxt.config.js The server cannot be loaded after being modified

yinfoyuan avatar Sep 28 '21 06:09 yinfoyuan

having the same issue here

mamdasan avatar Oct 23 '23 08:10 mamdasan

my issue here is solved. the problem was i was running my nuxt build not with 127.0.0.1. the problem is other than this dns, the you need https so the browser will trust and run your service worker. this dns 127.0.0.1 is trusted by most browsers.

mamdasan avatar Oct 28 '23 09:10 mamdasan