amp-app-banner: doesn't show up in AMP Viewer in Chrome on Android
How do we reproduce the issue?
Open the following link in Chrome on Android: https://google.com/amp/ampbyexample.com/components/amp-app-banner/
=> the app banner doesn't appear
//cc @ericlindley-g @mkhatib
I can also repro with the viewer link (as opposed to the AMP Cache link from the repro steps. The AMP Cache link works as expected for me)
Any thoughts on this, @mkhatib ?
Hey, I've managed to track this down to the lack of /s/ in the viewer URL to indicate that the page should be loaded over https.
This is probably the correct behavior when /s/ is omitted, the xhr-impl fails an assertion that the amp-access-control-allow-source-origin returned by the response to the manifest https://ampbyexample.com is not equal to http://ampbyexample.com (no https) hence the app banner fails to show.
Does this make sense?
@mkhatib — thanks for tracking this down!
Do we need to require that the original page be served through https in order to show the AMP banner in the viewer context? I know it's a requirement for the system banner (outside of the viewer context), but I assume that will take care of itself in the non-viewer Chrome + Android setting without AMP adding an additional behavior.
Also, I believe AMP by Example is served via HTTPS, and that the google viewer doesn't include an /s/ for HTTPS pages. If HTTPS is a requirement, can we use a different method to determine?
Do we need to require that the original page be served through https in order to show the AMP banner in the viewer context?
The problem was the mismatch between where the page was served and where the manifest was pointing. But in general yes, since we already enforce manifest to be served from https the host must be on https as well.
Also, I believe AMP by Example is served via HTTPS, and that the google viewer doesn't include an /s/ for HTTPS pages.
Can we make sure of this assumption? Cause if it's true, then our logic of getting the origin source URL is invalid:
const origin = domainOrHttpsSignal == 's'
? 'https://' + decodeURIComponent(path[3])
: 'http://' + decodeURIComponent(domainOrHttpsSignal);
And the Google Viewer seems to be embedding a link like:
https://cdn.ampproject.org/v/ampbyexample.com/components/amp-app-banner/... - without an /s/.
@mkhatib: The viewer will use /v/s if the page is HTTPS. What did you do to get iframe src above?
It works if you add the /s to the viewer url: https://www.google.com/amp/s/ampbyexample.com/components/amp-app-banner/
Got it — so the Google AMP Viewer will always add the /s/ to the url, and the Google AMP Cache will always add the /s/ to the URL, which amp-app-banner will look for and behave appropriately. It looks like it was my method of testing that was flawed in these cases.
@mkhatib What about other caches? Do we have a system that will work for those?
I am not entirely sure about other viewers. But it looks like yes this was a problem with the testing method - forgetting to add /s/ part of the viewer URL.
Closing this