响应必须包含AMP-Access-Control-Allow-Source-Origin 标头表单提交失败:错误:响应必须包含 AMP-Access-Control-Allow-Source-Origin标题
我来自
<form id="aa" name="aa" method="post" target="_top" action-xhr="/gonder.asp" enctype="multipart/form-data">
<div class="ampstart-input inline-block relative m0 p0 mb3">
<input class="block border-none p0 m0" type="text" name="adSoyad" placeholder="Ad Soyad" required>
<input class="block border-none p0 m0 telefonKontrol" type="tel" name="telefon" maxlength="10" placeholder="5XX1112233" pattern="[1-9]{1}[0-9]{9}" required>
</div>
<input value="GÖNDER" class="ampstart-btn caps user-valid valid" type="submit">
<div submit-success>
<template type="amp-mustache">
<p>Bilgileriniz bize ulaştı. Size en kısa sürede geri dönüş yapılacaktır.</p>
</template>
</div>
</form>
这个c#代码
public virtual ActionResult AmpRedirect(string redirectUrl, string __amp_source_origin)
{
if (redirectUrl != string.Empty)
{
HttpContext.Response.AddHeader("AMP-Redirect-To", redirectUrl);
HttpContext.Response.AddHeader("AMP-Access-Control-Allow-Source-Origin", __amp_source_origin);
HttpContext.Response.AddHeader("Access-Control-Expose-Headers", "AMP-Redirect-To, AMP-Access-Control-Allow-Source-Origin");
}
HttpContext.Response.AddHeader("Content-type", "text/json");
return Json(new {Content = ""});
}
我需要一个代码来使用经典的asp
答案 0 :(得分:2)
检查此CORS Security in AMP github指南:
AMP中的CORS安全
AMP CORS安全协议由三部分组成:
CORS Origin标头AMP-Same-Origin自定义标头源origin 通过__amp_source_origin进行限制确保安全请求
验证CORS Origin标头
CORS端点通过Origin HTTP接收请求源 头。端点应限制请求以仅允许以下内容 起源:
Google AMP Cache子域:https://.cdn.ampproject.org(例如, https://nytimes-com.cdn.ampproject.org)Google AMP Cache(旧版): https://cdn.ampproject.org Cloudflare AMP缓存:https://. amp.cloudflare.com发布商自己的来源