title: How to set service worker on one fixed root
body: <p>Need your help please. I want to use the web starter kit on a own build php mvc framework. A part of the web starter kit is the use of a service worker.</p>
  
  <p>In my root folder (called public in my case) i have the service worker file and i register it like the reconommend why like this:</p>
  
  <pre><code>if ('serviceWorker' in navigator &amp;&amp;
      (window.location.protocol === 'https:' || isLocalhost)) {
      navigator.serviceWorker.register('service-worker.js')
          .then(function(registration) {
  ....
  </code></pre>
  
  <p>If i try to call the root (index.php) page it works well. But if i try to call any route, the service worker will be called twice and one gives me an error and the second works fine. I found out, that first try with the thrown error just add the service-worker.js on my controller path.</p>
  
  <p>For example, if I try to open mydomain/controller i get an error, that the mydomain/controller/service-worker.js could not found. Sure, there inst any.</p>
  
  <p>Have one of you an idea, how to set that the service-worker will be called only in the root??</p>
  
  <p>Hope, you can help and thank you very much</p>