title: Service Worker Registration Failed
body: <p>I am currently working on service worker to handle push notification in browser. Currently I am having this "SW registration failed error":</p>
  
  <blockquote>
    <p>SW registration failed with error SecurityError: Failed to register a ServiceWorker: The URL protocol of the current origin ('null') is not supported.</p>
  </blockquote>
  
  <p>Check <code>client1.html</code> and <code>service-worker.js</code> file below:</p>
  
  <p><strong>service-worker.js</strong></p>
  
  <pre class="lang-js prettyprint-override"><code>console.log('Started', self);
  self.addEventListener('install', function(event) {
    self.skipWaiting();
    console.log('Installed', event);
  });
  self.addEventListener('activate', function(event) {
    console.log('Activated', event);
  });
  self.addEventListener('push', function(event) {
    console.log('Push message received', event);
  });
  
  </code></pre>
  
  <p><strong>client1.html</strong></p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;!doctype html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;Client 1&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;script&gt;
        if('serviceWorker' in navigator){
          // Register service worker
          navigator.serviceWorker.register('service-worker.js').then(function(reg){
            console.log("SW registration succeeded. Scope is "+reg.scope);
          }).catch(function(err){
            console.error("SW registration failed with error "+err);
          });
        }
      &lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Can anyone help with this issue?</p>