partytown icon indicating copy to clipboard operation
partytown copied to clipboard

[🐞] partytown-sw.js The script does not have a MIME type

Open AkshayKumarDhage opened this issue 10 months ago • 1 comments

Describe the bug

I am trying to integrate Partytown in my website and following the HTML integration. And have included partytown.js as inline script in

. And have configured window.partytown with correct path for "lib".

Since partytown.js requests the partytown-sw.js, In chrome browser network tab I get 200 status for partytown-sw.js,

But in console it throws error: DOMException: Failed to register a ServiceWorker for scope ("https://www.example.com/static/js/src/partytown/lib/") with script ("https://www.example.com/static/js/src/partytown-sw.js"): The script does not have a MIME type

I checked if there is any issue in the path of file but that's not the case, as going to link https://www.example.com/static/js/src/partytown-sw.js gives the correct JS file in browser.

I definitely think this issue is related to Partytown service worker file, as I came accross a blog where some author mentioned above same MIME type issue with the loading of Partytown Service Worker file. Blog link: https://maxchadwick.xyz/blog/experimenting-with-partytown

(I tried with latest version of Partytown, it still has this error)

Any quick help or fix or workaround on this is highly appreciated!!

Reproduction

https://maxchadwick.xyz/blog/experimenting-with-partytown

Steps to reproduce

  1. Do HTML integration for Partytown
  2. Include partytown.js as inline script in
  3. Now go to Chrome/Firefox browser and load the website
  4. Check the console, it will throw error that partytown-sw.js file doesn't have a MIME type.

(I only tried the latest Partytown version, not sure about old versions)

Browser Info

Chrome, Firefox

Additional Information

No response

AkshayKumarDhage avatar Sep 21 '23 18:09 AkshayKumarDhage

The mime type is controlled by your server... I think you need to configure it?

mhevery avatar Sep 24 '23 23:09 mhevery