Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

amp-html http protocol restriction

I have added AMP to my project and trying to figure out an validation issue with http protocol in form action. In the official example, I can see that it is possible to have relative URL: https://github.com/ampproject/amphtml/blob/master/examples/forms.amp.html

1) when I try to use relative URL it becomes invalid

The relative URL '/amp/someurl' for attribute 'action' in tag 'form' is disallowed.

2) when I try to use absolute URL, it complains about protocol

Invalid URL protocol 'http:' for attribute 'action' in tag 'form'.

the last error disappears when I use https instead of http. But the problem is that the website does not have https and the form is being used just for searching.

Maybe I have to use some <amp-iframe> in order to solve it?

like image 454
Vazgen Manukyan Avatar asked Dec 05 '25 07:12

Vazgen Manukyan


1 Answers

As stated in the <amp-form> specifications, you can't use a relative path for the action attribute and it must be https. The same goes for <amp-iframe>, you need https for the src attribute.

The reason for the mandatory https protocol is because AMP pages are cached on Google AMP servers and when served from AMP servers, they will be delivered over https. Now if you had http requests in your page, then they will be blocked for security reasons.

like image 126
Andrew Avatar answered Dec 08 '25 02:12

Andrew



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!