Ionic5 PWA Web push Notifications not working in real server

I was integrated web push notifications to my Ionic5 project. which is working fine when I did ionic serve or run broswer but it is not working when I hosted in Tomcat server, getting following error.

FirebaseError: Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker for scope ('http://localhost:8080/firebase-cloud-messaging-push-scope’)) with script ('http://localhost:8080/firebase-messaging-sw.js’)::slight_smile: A bad HTTP response code (404) was received when fetching the script. (messaging/failed-service-worker-registration).

I followed this tutorial and did same thing
https://devdactic.com/ionic-pwa-web-push/

please help me to fix this.
thank you

1 Like