next-pwa icon indicating copy to clipboard operation
next-pwa copied to clipboard

The script has an unsupported MIME type ('text/html').

Open AllanOliveiraM opened this issue 2 years ago • 1 comments

Summary

I caught this error on Sentry:

SecurityError: Failed to register a ServiceWorker for scope ('my_domain.../') with script ('my_domain.../sw.js'): The script has an unsupported MIME type ('text/html').

I have done extensive research and found that other people have encountered the same issue with CRA, but I'm having trouble understanding what to do with Next. I have several clients who are unable to install the PWA due to this error, mostly on mobile devices. What's interesting is that some of them are up to date and should support PWAs.

Versions

  • "next": "^13.3.4",
  • "next-pwa": "^5.6.0",
  • "react": "^18.2.0",

How To Reproduce

I couldn't reproduce it in a controlled environment. It's happening on multiple people's devices. I'm able to capture the exceptions with Sentry, and when I analyze what people are seeing on Hotjar, they're indeed unable to install the app.

Steps to reproduce the behavior:

Apparently, customers access the website, and during the script loading, the browser already raises this exception.

Expected Behaviors

It should be possible to register the service worker.

Screenshots

image

😢

Any ideas on where should I start to solve this?

AllanOliveiraM avatar Jul 06 '23 13:07 AllanOliveiraM

I found this issue https://github.com/shadowwalker/next-pwa/issues/479 Maybe? I'm not sure if it's the same case, but there's a good chance it is. I tried accessing the /sw.js file to see if it was there, and yes, it was. Everything works fine on the computer.

AllanOliveiraM avatar Jul 06 '23 14:07 AllanOliveiraM