【问题标题】:Response must contain the AMP-Access-Control-Allow-Source-Origin header?响应必须包含 AMP-Access-Control-Allow-Source-Origin 标头?
【发布时间】:2019-05-25 07:26:34
【问题描述】:

我在浏览器中收到这些错误

“响应必须包含 AMP-Access-Control-Allow-Source-Origin 标题"

“表单提交失败:错误:响应必须包含 AMP-Access-Control-Allow-Source-Origin 标头​​​"

php

<?php
if (isset($_POST['iletisimg'])) {
    $status = 0;
    $ip = $_SERVER['REMOTE_ADDR'];
    $time = time();
    if (empty($post->isim) || empty($post->mesaj) || empty($post->email)) {
        $yorumcevap = "Lütfen tüm alanları eksiksiz doldurunuz!";
    } else {
        $yorumekle = $db->query("insert into iletisim (isim,mesaj,email,konu,durum,tarih,ip) values ('$post->isim', '$post->mesaj', '$post->email', '$post->konu', 0, '$time', '$ip')");
        if ($yorumekle) {
            $yorumcevapok = "Teşekkürler. Talebiniz alındı.";
        } else {
            $yorumcevap = "Hata! Lütfen tekrar deneyin.";
        }
    }
}

html

<html amp lang="tr">
<head>
    <script async src="https://cdn.ampproject.org/v0.js"></script>
    <script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script>
</head>
<body>
<form method="post" action-xhr="#" autocomplete="off">
    <?PHP echo '<p>' . $yorumcevap . '</p>'; ?>
    <input type="text" class="isim" name="isim" autofocus required>
    <input type="text" class="isim" name="konu" required>
    <input type="text" class="isim" name="email" required>
    <textarea name="mesaj" cols="80" rows="8" required></textarea>
    <input type="submit" value="Gönder" name="iletisimg">
</form>
</body>
</html>

如何编辑它以避免这些错误?

【问题讨论】:

标签: php html forms amp-html


【解决方案1】:

您需要确保您的 CORS 设置符合 here 记录的 AMP 要求

还有一个类似的问题提供了有关如何正确设置响应标头的代码: AMP Access Control Allow Source Origin header Issue

【讨论】:

    猜你喜欢
    • 2018-06-27
    • 2018-07-15
    • 2018-05-18
    • 1970-01-01
    • 2018-08-01
    • 2015-05-04
    • 1970-01-01
    • 2017-12-28
    • 2019-10-10
    相关资源
    最近更新 更多