Service worker fetching result in 400 on cloudflare ipfs gateway. works on other gateways

I am having issue with service worker when served from cloudflare ipfs gateway. It return a 400


:method: GET
:path: /ipfs/QmRm77vo2VgQULULHUQXssAAux3cSAqSnEaZSU6FS1paHP/sw.js
:scheme: https
accept: */*
accept-encoding: gzip, deflate, br
accept-language: en-US,en;q=0.9
cache-control: max-age=0
cookie: __cfduid=dbe69e3393e171e83e8a2978322a935231599656925
sec-fetch-dest: serviceworker
sec-fetch-mode: same-origin
sec-fetch-site: same-origin
service-worker: script
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4252.0 Safari/537.36


cf-ray: 5d0123cacfc51e0a-MAN
cf-request-id: 051494b2b800001e0a8b19e200000001
content-length: 68
content-type: text/plain;charset=UTF-8
date: Wed, 09 Sep 2020 13:08:45 GMT
expect-ct: max-age=604800, report-uri=""
server: cloudflare
status: 400
vary: Accept-Encoding

It works fine on other ipfs gateways. Does cloudflare block service worker on ipfs ?
If so why ?
Any way around to have PWA working on ipfs urls ?

with curl

this works


this fails:

 curl -H "service-worker: script"

Hello @wighawag that is quite interesting, do you mind opening a ticket so we can investigate that more?
Please paste the ticket number here when you ready.

Please share with us a HAR file demonstrating the issue?

Make sure to set up your Browser’s Developer tools to “Preserve Logs”.
more detailed information for sending debugging info:

I would suggest sending 2 har files, one with DNS over Cloudflare and one without.

1 Like

Thanks for the quick reply.
I created a ticket : 1975170
Re 2 HAR files, There is no DNS over Cloudflare option since the issue is on Cloudflare IPFS gateway itself
So I send the HAR file from browsing :


Hi @stefano1
Any updates on the issue? The ticket got closed, arguing that as a free user, they do not have time to look at it.
But the issue has nothing to do with me or my application, it affects every user of cloudflare ipfs gateway.

It would be great to have an update on this and whether you intends to fix it.


Hey @wighawag

we are preventing service workers from fetching our ipfs gateway, so you won’t be able to register the service-worker from and this is the reason that you get the 400 error.
We have created an internal ticket with the IPFS engineering team, so you and anyone else will be able to register their service-workers to any DIR two levels depth from the root DIR.

hope that makes sense.

1 Like

Hi @stefano1, thanks for the reply
It make sense, note that my service worker scope is already 2 level deep.
So I guess once they implement it, my website service worker will work ?

1 Like

Hi @wighawag,

This issue should be solved now. We have loosen the criteria to register a service worker.

Please post if you are still encountering issues.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.