Reputation: 1
Response must contain the AMP-Access-Control-Allow-Source-Origin header Form submission failed: Error: Response must contain the AMP-Access-Control-Allow-Source-Origin header
my from
<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>
this c# code
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 = ""});
}
I needed a code to work with classic asp
Upvotes: 0
Views: 3119
Reputation: 17613
Check this CORS Security in AMP github guide:
CORS Security in AMP
The AMP CORS security protocol consists of three components:
The CORS Origin header The AMP-Same-Origin custom header Source origin restrictions via __amp_source_origin Ensuring secure requests
Verify the CORS Origin header
CORS endpoints receive the requesting origin via the Origin HTTP header. Endpoints should restrict requests to allow only the following origins:
Google AMP Cache subdomain: https://.cdn.ampproject.org (for example, https://nytimes-com.cdn.ampproject.org) Google AMP Cache (legacy): https://cdn.ampproject.org Cloudflare AMP Cache: https://.amp.cloudflare.com The Publisher’s own origins
Upvotes: 2