title: ServiceWorker registration failed: DOMException: Only secure origins are allowed (see: https://goo.gl/Y0ZkNV)
body: <p>I wrote code to get GCM id to send chrome push notifications. I wrote below code to get GCM id.</p>
  
  <pre><code>var ChromePushManager = function (serviceWorkerPath, callback) {
      if ('serviceWorker' in navigator) {
          navigator.serviceWorker.register(serviceWorkerPath).then(function (registration) {
              // Registration was successful 
              console.log('ServiceWorker registration successful with scope: ', registration.scope);
  
              registration.pushManager.subscribe({userVisibleOnly: true}).then(function (subscription) {
                  console.log("subscription.subscriptionId: ", subscription.subscriptionId);
                  console.log("subscription.endpoint: ", subscription.endpoint);
  
                  // TODO: Send the subscription subscription.endpoint
                  // to your server and save it to send a push message
                  // at a later date
                  var register = ChromePushManager.getRegistrationId(subscription);
                  callback(null, register);
              });
          }).catch(function (err) {
              // registration failed :(
              console.log('ServiceWorker registration failed: ', err);
          });
      } else {
          callback('Service workers aren\'t supported in this browser.', null);
      }
  };
  
  ChromePushManager.getRegistrationId = function (pushSubscription) {
      if (pushSubscription.subscriptionId) {
          return pushSubscription.subscriptionId;
      }
  
      var endpoint = 'https://android.googleapis.com/gcm/send/';
      parts = pushSubscription.endpoint.split(endpoint);
  
      if (parts.length &gt; 1)
      {
          console.log("RegistrationId : " + parts[1]);
          return parts[1];
      }
  }
  
  var chromePushManager = new ChromePushManager('../js/service-worker.js', function (error, registrationId) {
                      if (error !== null) {
                          console.log(error);
                      }
  });
  </code></pre>
  
  <p>It is working fine in <a href="http://localhost:8080" rel="nofollow">http://localhost:8080</a>. I uploaded this code in server. I was trying to execute code in server. I was getting error.</p>
  
  <p>ServiceWorker registration failed:  DOMException: Only secure origins are allowed (see: <a href="https://goo.gl/Y0ZkNV" rel="nofollow">https://goo.gl/Y0ZkNV</a>).</p>
  
  <p>I don't know what this error says. Could you please any once explain me what this error mean and give me a solution to resolve this error at my server side.</p>
  
  <p>Thank you.</p>