title: FCM Web push notification unable to register the default service worker
body: <p>I am using FCM web app notification for send notification to browser.
  **I Got The following errors :</p>
  
  <ul>
  <li>1.A bad HTTP response code (404) was received when fetching the script.  ------ firebase-messaging-sw.js</li>
  <li>2..Failed to load resource: net::ERR_INVALID_RESPONSE</li>
  <li>3.Error -> messaging/failed-serviceworker-registration</li>
  <li>4.Error Message -> 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
  <a href="https://www.gstatic.com/firebasejs/4.6.0/firebase-messaging.js:6:14342" rel="nofollow noreferrer">https://www.gstatic.com/firebasejs/4.6.0/firebase-messaging.js:6:14342</a>↵
  at **</li>
  </ul>
  
  <p>My code below.</p>
  
  <pre><code>&lt;script src="https://www.gstatic.com/firebasejs/4.6.1/firebase.js"&gt;&lt;/script&gt;
  &lt;script src="https://www.gstatic.com/firebasejs/4.6.0/firebase-app.js"&gt;&lt;/script&gt;
  &lt;script src="https://www.gstatic.com/firebasejs/4.6.0/firebase-messaging.js"&gt;&lt;/script&gt;
  &lt;script&gt;
    // Initialize Firebase
    var config = {
      apiKey: "APIKEYXXXXXXXXXXXXXXXXXXXXX",
      authDomain: "fir-cloudmessaging-d3607.firebaseapp.com",
      databaseURL: "https://fir-cloudmessaging-d3607.firebaseio.com",
      projectId: "fir-cloudmessaging-d3607",
      storageBucket: "fir-cloudmessaging-d3607.appspot.com",
      messagingSenderId: "SENDERID123456789"
    };
    firebase.initializeApp(config);
  &lt;/script&gt;
  
  &lt;script&gt;
  
    if ('serviceWorker' in navigator) {
    window.addEventListener('load', function() {
      navigator.serviceWorker.register('firebase-messaging-sw.js').then(function(registration) {
        // Registration was successful
        console.log('ServiceWorker registration successful with scope: ', registration.scope);
      }, function(err) {
        // registration failed :(
        console.log('ServiceWorker registration failed: ', err);
      });
    });
  }
  const messaging = firebase.messaging();
  messaging.requestPermission()
  .then(function() {
    console.log('Notification permission granted.');
    // TODO(developer): Retrieve an Instance ID token for use with FCM.
    // ...
    console.log(messaging.getToken());
   // return messaging.getToken();
  })
  .then(function(token){
    console.log(token);
  })
  .catch(function(err) {
    console.log('Unable to get permission to notify.', err);
  });
  &lt;/script&gt;
  </code></pre>