vite-pwa / astro

Zero-config PWA Integration for Astro
https://vite-pwa-org.netlify.app/frameworks/astro
MIT License
187 stars 6 forks source link

examples/pwa-prompt SW not registering in Brave for Offline support #31

Open AustinFoss opened 9 months ago

AustinFoss commented 9 months ago

Starting from the pwa-prompt example in this repo I successfully got it working on my desktop with the node server, pnpm preview, shut down if the PWA was installed first.

However when I try to do the same from my mobile phone the offline support isn't working

On my development computer I'm using Brave, and on my Android am also using brave. On my laptop I did have to set the service working offline setting to in Dev Tools (ctrl + J) > Application > Service Workers > Offline, and I also did this on my Android's Brave browser over usb debugging.

Oddly in the USB debugging menu inspecting the PWA shows no registered service worker.

Could this possibly have to do with laptop accessing the PWA from localhost while the mobile browser is receiving it from the laptop's ip in the search bar? Having offline support on a mobile device is key for what I'm trying to prototype but haven't yet been able to get any on the existing examples to work offline on mobile.

userquin commented 9 months ago

I don't use Brave, I always use Chrome/Chromium in my sw tests (including Android Device via USB).

Check this entry https://docs.elk.zone/pwa#debugging-pwa-in-mobile-browsers and this tweet https://twitter.com/userquin/status/1606967107325165570

AustinFoss commented 9 months ago

I just tested it out on Chrome and got the same problem, see below screen shot of the remote debugging window and the absent service worker:

Screenshot from 2023-12-03 23-19-10

I'm very suspicious that it's the difference between accessing the PWA from a localhost url or my laptop's LAN IP. Because both in Chrome and Brave (on my laptop not mobile) when I navigate to localhost:5432 I get the registered service worker visible in that devtools menue from the screen shot, but when I navigate to 192.168.1.151:5432 on the same laptop (the url I was accessing the PWA with from my phone) the SW is once again missing.

I'm not sure how to spoof HTTPS after pnpm preview, the way I used to spoof it after pnpm dev doesn't seem to work; or if that would even overcome this SW blocking behavior.