title: Service Worker registration error: Unsupported MIME type ('text/html')
body: <p>I'm using <a href="https://github.com/facebook/create-react-app" rel="nofollow noreferrer">create-react-app</a> with an <a href="https://github.com/expressjs/express" rel="nofollow noreferrer">express</a> server.</p>
  <p><code>create-react-app</code> has a pre-configured ServiceWorker that caches local assets (<a href="https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app" rel="nofollow noreferrer">https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app</a>).</p>
  <p>The problem I encountered when I tried to publish on my server is that the <code>service-worker.js</code> file was available, but I was getting errors in my browser console when it tried to register it.</p>
  <p>On Firefox, I got this error:</p>
  <blockquote>
  <p>Error during service worker registration:</p>
  <blockquote>
  <p>TypeError: ServiceWorker script at <code>https://example.com/service-worker.js</code> for scope <code>https://example.com/</code> encountered an error during installation.</p>
  </blockquote>
  </blockquote>
  <p>On Chrome, I get the more descriptive error:</p>
  <blockquote>
  <p>Error during service worker registration: DOMException: Failed to register a ServiceWorker: The script has an unsupported MIME type ('text/html').</p>
  </blockquote>
  <p>Sure enough, if I look in the Network tab of my developer tools and search for the <code>service-worker.js</code> file, I can see that it has the wrong MIME type in the HTTP headers.</p>
  <p>I could not understand, though, why it has the wrong MIME type?</p>