So I have a service worker in order to implement FCM to my web app, and I can't fix the following issue.
This is my code:
importScripts("https://cdnjs.cloudflare.com/ajax/libs/firebase/9.6.9/firebase-app-compat.min.js", "https://cdnjs.cloudflare.com/ajax/libs/firebase/9.6.9/firebase-messaging-sw.min.js")
const firebaseApp = initializeApp({
...
});
getMessaging(firebaseApp);
console.log('Firebase messaging service worker is set up');
And these are the issues I get in the console
Uncaught DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'https://cdnjs.cloudflare.com/ajax/libs/firebase/9.6.9/firebase-app-compat.min.js' failed to load.
Uncaught DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'https://cdnjs.cloudflare.com/ajax/libs/firebase/9.6.9/firebase-messaging-sw.min.js' failed to load.
Any solutions?
Put the file that contain this script in public directory and try next script.
self.importScripts("https://cdnjs.cloudflare.com/ajax/libs/firebase/9.6.9/firebase-app-compat.min.js", "https://cdnjs.cloudflare.com/ajax/libs/firebase/9.6.9/firebase-messaging-sw.min.js")