PWA: Address bar showing up when redirectioning to subdomains

旧巷老猫 提交于 2020-06-13 06:20:10

问题


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?

app screen


回答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

  1. https://blog.hackages.io/migrating-a-service-worker-from-an-old-domain-to-your-new-domain-69236418051c
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!