表单提交失败:: Response must contain the AMP-Access-Control-Allow-Source-Origin header

Form submission failed:: Response must contain the AMP-Access-Control-Allow-Source-Origin header​

我想使用 amp-form 进行表单提交。正在将 text/data 发送到同一域内的数据库。

在提交一个简单的表单后,我收到了这个未捕获的错误: Form submission failed:: Response must contain the AMP-Access-Control-Allow-Source-Origin header​​​.

我用 Google 搜索了一下,大多数答案都指向我在 .htaccess 文档中设置 header,如下所示:

Header set Access-Control-Allow-Origin "*"

我正在继续寻找答案。

出于安全原因,AMP 要求某些 headers 出现在 cross-origin HTTP 响应中,包括 AMP-Access-Control-Allow-Source-Origin

有关完整列表,请参阅 CORS Requests in AMP 文档。