AMP-Access-Control-Allow-Source-Origin标头 - 需要帮助

时间:2017-11-26 09:09:53

标签: html controls access amp-html

我正在尝试第一次为我的网站实施AMP并获得

这样的错误

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

我之前尝试过,但没有用。

抱歉PS因为http://不允许我不得不将代码中的链接更改为http-mydomain.com

任何帮助表示赞赏。谢谢

    <code>      <form method="post"
  class="p2"
  action-xhr="//mydomain.com/limoz/mobile/chkfare.php"
  target="_top">
  <div class="ampstart-input inline-block relative m0 p0 mb3">
    <label>Pickup Address</label>
    <input type="text"
      class="block border-none p0 m0"
      name="caddr" id="caddr" required>
    <label>Drop-Off Address</label>
    <input type="text"
      class="block border-none p0 m0"
      name="cdest" id="cdest" required>
<label>Travel Date &amp; Time</label><br>
      <input type="date"
      class="block border-none p0 m0"
      name="csdate" id="csdate" required>

      <input type="time"
      class="block border-none p0 m0"
      name="cstime" id="cstime" required>
<label>No. of Passengers</label><br>
      <select name="csnop" id="csnop">
                  <?php for($x = 1;$x <= 20; $x++) { ?>
                  <option value="<?php echo $x; ?>"><?php echo $x; ?> PAX</option>
                  <?php } ?>
                </select>


  </div>
  <div id="dfare"></div>
  <div id="map"></div><br><bR>
  <input type="submit"
    value="  Get Fare  ">
  <!--<div submit-success>
    <template type="amp-mustache">
      Success! Thanks {{name}} for trying the
      <code>amp-form</code> demo! Try to insert the word "error" as a name input in the form to see how
      <code>amp-form</code> handles errors.
    </template>
  </div>
  <div submit-error>
    <template type="amp-mustache">
      Error! Thanks {{name}} for trying the
      <code>amp-form</code> demo with an error response.
    </template>
  </div>-->
</form>
<?php if(!empty($_POST)){
        $domain_url = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]";
        header("Content-type: application/json");
        header("Access-Control-Allow-Credentials: true");
        header("Access-Control-Allow-Origin: ". str_replace('.', '-','http-taxiwebsitedesigner.net') .".cdn.ampproject.org");
        header("AMP-Access-Control-Allow-Source-Origin: " . $domain_url);
        header("Access-Control-Expose-Headers: AMP-Access-Control-Allow-Source-Origin");
        header("AMP-Redirect-To: http-mydomain.com/limoz/mobile/chkfare.php");
        header("Access-Control-Expose-Headers: AMP-Redirect-To, AMP-Access-Control-Allow-Source-Origin"); 
        echo json_encode(array('successmsg'=>'data post'));
        exit;
} ?></code>

0 个答案:

没有答案
相关问题