Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Messaging: We are unable to register the default service worker. #701

Open
hakimov-dev opened this issue Apr 7, 2023 · 2 comments
Open

Comments

@hakimov-dev
Copy link

hakimov-dev commented Apr 7, 2023

I'm trying to add Firebase Cloud Messaging to a simple static site with vanilla Js. The notifications seem to be working in localhost(i.e serve . But when I deploy to GitHub Pages it causes the following error

Console:
FirebaseError: Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker for scope ('https://sample.github.io/firebase-cloud-messaging-push-scope') with script ('https://sample.github.io/firebase-messaging-sw.js'): A bad HTTP response code (404) was received when fetching the script. (messaging/failed-service-worker-registration). at rt.<anonymous> (https://www.gstatic.com/firebasejs/7.14.2/firebase-messaging.js:1:31316) at https://www.gstatic.com/firebasejs/7.14.2/firebase-messaging.js:1:1935 at Object.throw (https://www.gstatic.com/firebasejs/7.14.2/firebase-messaging.js:1:2040) at i (https://www.gstatic.com/firebasejs/7.14.2/firebase-messaging.js:1:834)

@asleeguilez
Copy link

it could be that you are missing the file "messaging/firebase-messaging-sw.js"

@fkazemi5236
Copy link

it could be that you are missing the file "messaging/firebase-messaging-sw.js"

I am facing the same problem with Firebase 10 in React 18 project. The file is also in the root of the project, but this error is displayed during execution and when browser access is created for notifications.
1
2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants