0

Response Headers

Access-Control-Allow-Credentials:true
Access-Control-Allow-Headers:Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token
Access-Control-Allow-Methods:GET,PUT,POST,DELETE,OPTIONS
Access-Control-Allow-Origin:https://www-example-com.cdn.ampproject.org
AMP-Access-Control-Allow-Source-Origin:https://www.example.com
AMP-Control-Expose-Headers:AMP-Access-Control-Allow-Source-Origin
AMP-Same-Origin:true
Cache-Control:no-cache
Content-Length:3
Content-Type:text/html; Charset=utf-8
Date:Thu, 18 Jan 2018 11:47:52 GMT
Server:Microsoft-IIS/8.5
X-Powered-By:ASP.NET
X-Powered-By-Plesk:PleskWin

Request Headers

Accept:application/json
Accept-Encoding:gzip, deflate, br
Accept-Language:tr-TR,tr;q=0.9,en-US;q=0.8,en;q=0.7
Connection:keep-alive
Content-Length:707
Host:www.example.com
Origin:https://www-example-com.cdn.ampproject.org
Referer:https://www-example-com.cdn.ampproject.org/v/s/www.example.com/amp/gc/hbt.html?usqp=adadadas&amp_js_v=0.1
User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1

Query String Parameters

__amp_source_origin:https://www.example.com

not working https://www.google.com.tr/amp/s/www.example.com/amp

working www.example.com/amp

ERROR CODE

  • 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​​​

waiting for your help

1 Answer 1

0

In PHP we ca do like this:

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('.', '-','https://example.com') .".cdn.ampproject.org");
        header("AMP-Access-Control-Allow-Source-Origin: " . $domain_url);
        header("AMP-Redirect-To: https://example.com/thankyou.amp.html");
        header("Access-Control-Expose-Headers: AMP-Redirect-To, AMP-Access-Control-Allow-Source-Origin"); 
        echo json_encode(array('successmsg'=>'data post'));
        exit;
}

Please make sure that domain url should be https

Replace https://example.com/ to your desired url

Sign up to request clarification or add additional context in comments.

2 Comments

Why are you adding Access-Control-Expose-Headers twice?
@mikeswright49, Yes Its require once, Thanks for corrected me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.