StreamSaver.js icon indicating copy to clipboard operation
StreamSaver.js copied to clipboard

404 in serviceworker when downloading file

Open rowanG077 opened this issue 3 years ago • 8 comments

Hi Jimmy,

Thank you for your hard work on this library! I have an issue which I have no clue what is going on. I'm hosting mitm.html and sw.js myself on a secured server. I point my local dev server to this instances as well as production. On the dev server this works fine. I can streaming download files and I can see it makes a download request succesfully to the URL:

https://xxxx.com/localhost:8080/608211/0ce02f4f-4502-4d15-acc2-4e46c8866f3a.zip

A nice 200 status is returned. But when I publish my app to the same url and then try to streaming download I get a 404 from:

https://xxxx.com/xxxx.com/843365/5f6d3487-1fae-48fd-85ff-21139e991688.zip

Is there something else I need to setup for hosting these files on my own?

rowanG077 avatar Jul 21 '21 12:07 rowanG077

Hmm, is the service worker installed successfully. it can't be installed on insecure sites...

jimmywarting avatar Jul 21 '21 14:07 jimmywarting

the site has https with a valid certificate. For the record the pages in the URLS don't actually exist and will 404 when you go to them with the browser.

But I don't get that locally I can use the remote mitm.html and sw.js fine but when I go to the remote site it doesn't work...

How can I verify the service worker is installed successfully?

rowanG077 avatar Jul 21 '21 15:07 rowanG077

@rowanG077 look in the Application tab in Firefox DevTools

allengordon011 avatar Jul 22 '21 19:07 allengordon011

I got the service worker to register as I can see console.log I added appearing in the console. But firefox says in the service worker tab that there are no service workers.

Now I no longer get a 404... Just nothing happens.

rowanG077 avatar Jul 30 '21 00:07 rowanG077

@rowanG077 did you fix it? I have the same problem. I can access my hosted files (mitm.html and sw.js), but I get a 404 on the download. image

But my sw.js is with pending status, I don't know if it was supposed to behave like this. @jimmywarting image

ramonribeiro96 avatar Apr 27 '22 15:04 ramonribeiro96

Yes I was able to fix it by hosting mitm myself.

rowanG077 avatar Apr 27 '22 18:04 rowanG077

But then did you register the external sw.js? if you can help me, just so I have a path to follow, thank you

ramonribeiro96 avatar Apr 27 '22 21:04 ramonribeiro96

The following notes are important:

  • If in Firefox make sure cookies are enabled. Service workers don't work in Firefox if cookies are disabled. See here: https://bugzilla.mozilla.org/show_bug.cgi?id=1413615
  • Make sure to clear your browser data if you are developing. I had some issues in both chrome and firefox where I was developing and deploying

The project I used streamsaver for is opensource so you can look at the source: https://github.com/encryption4all/cryptify. I included the stream saver files in the project and deployed them with the app.

rowanG077 avatar Apr 27 '22 22:04 rowanG077