问题
I have a PWA that uses subdomains sometimes. The problem that I found happens when app redirects to another subdomain: Address bar shows up. This affects app-like experience.
Someone knows a solution to hide address bar when using subdomains?
回答1:
I also faced a similar issue when redirecting to subdomains. The address bar normally shows up when the PWA is not correctly set-up to behave like an app. In my case, the manifest.json
was not loading properly after redirecting.
This link may also prove useful - Chrome PWA
回答2:
I've found a blog post about this
- https://blog.hackages.io/migrating-a-service-worker-from-an-old-domain-to-your-new-domain-69236418051c
- https://github.com/0xClpz/migrating-service-workers-from-an-old-domain
It's an older post, and I have not been able to replicate their results in 2020 on Chrome 81 Android 10
Imagine you need to migrate your app from old-domain.com
to new-domain.com
You do 301 redirects for SEO reasons. All good, everything works, for new users, and users who didn't install the pwa to home screen.
When you try to open the old installed pwa, it sees the redirect to new-domain.com
. This is what triggers the address bar. It opens a new window within the pwa, because the domain is different. Just as if you were in some native app and tried to login via facebook or github.
The installed pwa never tries to load sw.js
, it just goes for the redirect, not giving you a chance to intercept anything.
For new users, when they visit new-domain.com
it offers them the usual pwa add to home screen prompt.
If by some chance, some new user visits old-domain.com
, they get redirected to new-domain.com
and are offered the pwa experience from new-domain.com
I'm not sure what the solution can look like.
I've been thinking about detecting server side if the request came of old installed pwa, and showing them some crafted page, instructing them to remove the old pwa from their homescreen, and then visiting the new domain...
来源:https://stackoverflow.com/questions/54580434/pwa-address-bar-showing-up-when-redirectioning-to-subdomains