amp cache link re-writes can cause validation error
If a page is served from cdn.ampproject.com/c/example.com/test.html and has amp-pixel with relative url <amp-pixel src="/pixel?status=bar"></amp-pixel> it will pass validations on edge but then cause error on page because of http vs https src <amp-pixel src="http://example.com/pixel?status=bar"></amp-pixel>
@dknecht In this case, the cache appears to have correctly made http determination, which is appropriately blocked. If this page is HTTPs, it should be accessed via cdn.ampproject.com/c/s/example.com/test.html (/c/s/). I'm not sure, however, why this page validates in the first place.
/cc @Gregable
@Gregable Slotting in backlog, but feel free to correct/update the milestone as needed
@dvoytenko, we allow relative URLs in <amp-pixel>, though not http. Changing this constraint breaks a lot of pages.
@Gregable I see. What happens is that our runtime rules are stricter - they require URL to, at least, contain hostname, but allows protocol-relative URLs. I agree, requiring this now in validator will be difficult as it will invalidate lots of docs that are currently valid (although with nonfunctional amp-pixel). I see two options:
- Ask publishers to change and update validator
- Allow non-host relative URLs and resolve the absolute URL against the origin. Or, alternatively, we can ask Cache to rewrite the URL for us.
I prefer the second option.
Filed an internal b/30000906 against Cache to rewrite pixel URLs against the origin.
I believe this is fixed now, please reopen if you find otherwise.