Skip to content

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

@hathemi

Description

@hathemi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions