Hello, I had a question about hosting a progressive web app over IPFS. Not sure if anyone’s tried this before, but I started using the Vite PWA (Astro | Examples | Vite PWA) and learning more about service workers.
The second of those two examples I linked I built locally and observed proper PWA behavior after building and previewing the project. Then after adding the dist directory to IPFS and pinning it using Gateway3’s free service, I tried navigating to it using https://.ipfs.gw3.io and the index page renders but no service worker gets registered and there’s no install PWA option in the browser.
Might someone be able to shed light on why there’s this discrepancy and if hosting a PWA over IPFS is possible?
Hey! Thank you for your reply, and apologies for my delay, was a busy week and wanted to tidy things up a bit before sharing to make finding a potential answer as smooth as possible.
After running pnpm i && pnpm build you can then use ipfs add -r dist/ to generate your CID locally which should currently produce this out put from the current mast branch:
When signed into my gw3.io account and given the option to upload a folder instead of a CID for pinning it produces this CID: bafybeihlgg2jvdijlwhhcsnbfzubjiymuipm24bss6ilam2d4obflh5c6q
When viewing that dist folder over https I get the desired offline PWA behavior but when viewing through an SSL secured ipfs gateway that isolates CIDs into subdomains PWA behavior doesn’t appear to be available.
Thank you very much again and I do appreciated any insights as to why PWA behavior is being blocked here.
My reason for using gw3 as my pinning service was it’s the only I came across, may be mistaken, who offered a free tier but also provided a CID sub-domain gateway. Every other service, even though a free tier was advertised still asked for payment info up front. Even though gw3 is listed as a sub-domain gateway on the IPFS status page (Public Gateway Checker | IPFS) they seem to redirect those subdomains to a much longer url and my original link now seems to be blocked with a “permission” error of some sort.
Cloudflare, even though they won’t pin it for me without payment info for their free tier, picks up the pinned dist folder from gw3’s node and provides proper sub-domain isolation without a subsequent redirect. Now I seem to have the expected offline PWA support from that gateway.
Although I’ve not had to do any further modifications to my PWA deployment to get it working through CF’s gateway, I would be curious to know more about the redirects and custom 404s link you referenced previously in case it becomes relevant later.