amp-html http协议限制
amp-html http protocol restriction
我已将 AMP 添加到我的项目中,并试图找出表单操作中 http
协议的验证问题。在官方的例子中,我看到可以有relative URL: https://github.com/ampproject/amphtml/blob/master/examples/forms.amp.html
1) 当我尝试使用相对 URL 它变得无效
不允许在标记 'form' 中属性 'action' 的相对 URL '/amp/someurl'。
2) 当我尝试使用绝对 URL 时,它会抱怨协议
标签 'form' 中属性 'action' 的 URL 协议 'http:' 无效。
当我使用 https
而不是 http
时,最后一个错误消失了。但问题是该网站没有 https
并且该表格仅用于搜索。
也许我必须使用一些 <amp-iframe>
才能解决它?
如 <amp-form>
specifications 中所述,您不能为 action
属性使用相对路径,它必须是 https
。 <amp-iframe>
也是如此,你需要 https
作为 src
属性。
强制性 https
协议的原因是因为 AMP 页面缓存在 Google AMP 服务器上,当从 AMP 服务器提供服务时,它们将通过 https
传送。现在,如果您的页面中有 http
个请求,出于安全原因,它们将被阻止。
我已将 AMP 添加到我的项目中,并试图找出表单操作中 http
协议的验证问题。在官方的例子中,我看到可以有relative URL: https://github.com/ampproject/amphtml/blob/master/examples/forms.amp.html
1) 当我尝试使用相对 URL 它变得无效
不允许在标记 'form' 中属性 'action' 的相对 URL '/amp/someurl'。
2) 当我尝试使用绝对 URL 时,它会抱怨协议
标签 'form' 中属性 'action' 的 URL 协议 'http:' 无效。
当我使用 https
而不是 http
时,最后一个错误消失了。但问题是该网站没有 https
并且该表格仅用于搜索。
也许我必须使用一些 <amp-iframe>
才能解决它?
如 <amp-form>
specifications 中所述,您不能为 action
属性使用相对路径,它必须是 https
。 <amp-iframe>
也是如此,你需要 https
作为 src
属性。
强制性 https
协议的原因是因为 AMP 页面缓存在 Google AMP 服务器上,当从 AMP 服务器提供服务时,它们将通过 https
传送。现在,如果您的页面中有 http
个请求,出于安全原因,它们将被阻止。