gauntface / web-push-book

Web Push Book
https://web-push-book.gauntface.com
226 stars 55 forks source link

Web push demo page service worker script has an unsupported MIME type #174

Closed phenax closed 3 years ago

phenax commented 3 years ago

The web push notification demo doesn't work because the service worker couldn't be registered.

Uncaught (in promise) DOMException: Failed to register a ServiceWorker for scope ('https://web-push-book.gauntface.com/demos/notification-examples/') with script ('https://web-push-book.gauntface.com/demos/notification-examples/service-worker.js'): The script has an unsupported MIME type ('binary/octet-stream').

part-2020_10_02_20_26_51

Browser: Chromium 80

phenax commented 3 years ago

It seems to be working properly when I ran it on my local machine. I think re-deploying/fresh install of dependencies would do it. Or you can explicitly register a route /service-worker.js that loads the file with the right content-type header.

gauntface commented 3 years ago

When you load https://web-push-book.gauntface.com/demos/notification-examples/service-worker.js in a tab, what is the content-type?

The site releases every Sunday and I've just tried it and get text/javascript for the content but I'm testing in Chrome 85.

phenax commented 3 years ago

Even curl is giving me a binary/octet-stream.

part-2020_10_04_11_19_58

gauntface commented 3 years ago

I'm afraid I can't reproduce this is. Is it still an issue?

$ curl -I https://web-push-book.gauntface.com/demos/notification-examples/service-worker.js
HTTP/2 200 
date: Wed, 30 Dec 2020 22:20:54 GMT
content-type: application/javascript
content-length: 5787
set-cookie: __cfduid=dc3aaf21c6099145ef9ee3e73b67ee9e81609366854; expires=Fri, 29-Jan-21 22:20:54 GMT; path=/; domain=.gauntface.com; HttpOnly; SameSite=Lax; Secure
x-amz-id-2: 8FQ5ww4k8F/Qh9dZ5E7SQftAWCOwYigEFcnn4SOHmgmWS//M3A2nxmSWuOQwFBJSgBWv/PUuC54=
x-amz-request-id: F318CC160957AD9B
cache-control: 'max-age=31104000'
last-modified: Sun, 27 Dec 2020 03:12:32 GMT
etag: "787f5aaa9ac33e50bec1621c335e3cca"
cf-cache-status: HIT
age: 50806
accept-ranges: bytes
cf-request-id: 075756751200000293ca1e5000000001
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report?s=ySp8X3CN%2FlBhJyTxH4uoyHgq%2FWrz8JOiy%2FTTn7wX8%2FiwHQm04E17KYnNaRlesHuRr0HozerVm%2BIP4K4tP68S%2BThoKCre2NTutgTeqxMYIXhcXiQrHdjHMvfyy38%3D"}],"group":"cf-nel","max_age":604800}
nel: {"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 609f269b5f820293-SJC
phenax commented 3 years ago

The issue seems to have fixed itself. It is working now! :)