How To Fix AMP CORS Header Error For WordPress

Trying to use AMP forms with action-xhr attributes and getting the Response must contain the AMP-Access-Control-Allow-Source-Origin header error? All you may need is to allow these in your .htaccess file.

Fixing the header error using .htaccess

To allow these headers, you need to first open your .htaccess file located on your website’s server.

  1. Open your FTP client such as FileZilla and connect to your server;
  2. Locate your .htaccess file (normally found inside the public_html folder);
  3. Edit this file and add the code snippet below.
Header set Access-Control-Allow-Origin '​'
Header set AMP-Access-Control-Allow-Source-Origin ''

SSL certificates

Note that it may be that you need an SSL certificate for your website for this to work.