title: We are unable to register the default service worker
body: <p>I am having the file firebase-messaging-sw.js, which is visible in the networks, logging message in the console too. But sill I am getting :</p>
  
  <pre><code>An error occurred while retrieving token.  FirebaseError: Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker: A bad HTTP response code (404) was received when fetching the script. (messaging/failed-serviceworker-registration).
      at https://www.gstatic.com/firebasejs/6.6.1/firebase-messaging.js:1:29909:
  </code></pre>
  
  <p>I have tried to check the console and also debug, but not sure what is error is.</p>
  
  <p>the firebase-messaging-sw.js file contains: </p>
  
  <pre><code>importScripts('https://www.gstatic.com/firebasejs/4.1.3/firebase-app.js');
  importScripts('https://www.gstatic.com/firebasejs/4.1.3/firebase-messaging.js');
  console.log("in sw page");
  </code></pre>
  
  <p>the index.html is having: </p>
  
  <pre><code>firebase.initializeApp({
                  apiKey: "XXXXXX",
                  authDomain: "XXXX-XXXXX.firebaseapp.com",
                  databaseURL: "XXXXXXX",
                  projectId: "XXXXXX",
                  storageBucket: "",
                  messagingSenderId: "XXXXXXX",
                  appId: "XXXXX"
                });
                  //  // Initialize Firebase
                  const messaging = firebase.messaging();
              Notification.requestPermission().then((permission) =&gt; {
                if (permission === 'granted') {
                  navigator.serviceWorker.register('firebase-messaging-sw.js')
                  console.log('Notification permission granted.');
                      messaging.getToken().then((currentToken) =&gt; {
                        if (currentToken) {
                          console.log(currentToken);
                        } else {
                          // Show permission request.
                          console.log('No Instance ID token available. Request permission to generate one.');
  
                        }
                      }).catch((err) =&gt; {
                        console.log('An error occurred while retrieving token. ', err);
                      });
                } else {
                  console.log('Unable to get permission to notify.');
                }
              });
  </code></pre>
  
  <p>I'm expecting to get a token once the user clicks on allow.
  What could be the reason? And any resolution for it?</p>