vuejs-templates / pwa

PWA template for vue-cli based on the webpack template
MIT License
3.04k stars 506 forks source link

Service Worker Error TypeError: Failed to register a ServiceWorker: A bad HTTP response code (404) was received when fetching the script. #204

Open hathemi opened 5 years ago

hathemi commented 5 years ago

i want to connect to my application by phone and save token device in firestore.I run my app on https://192.IP address. I can sign in but token is not added to my firestore. if i run my app on http://localhost, i'am able to save my device token. but not on phone. this is how i call firebase-messaging-sw.js

window.addEventListener('load', () => {

  if ('serviceWorker' in navigator) {

      navigator.serviceWorker.register('/firebase-messaging-sw.js')
          .then(registration => {

              messaging.useServiceWorker(registration)

              initializePush()
          })
          .catch(err => console.log('Service Worker Error', err))
  }

}) i always get this error. Service Worker Error TypeError: Failed to register a ServiceWorker: A bad HTTP response code (404) was received when fetching the script.