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?
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.