On a subdomain (de.website.com) of my website (website.com) the CORS policy blocks admin-ajax.php causing issues with the functionality of the website.
The following error appears on the console : Access to XMLHttpRequest at 'https://website.com/wp-admin/admin-ajax.php' from origin 'https://de.website.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I have managed to fix similar issues for icons (.woff files etc) blocked by CORS policy adding some lines (see below) to nginx.conf, but the same approach to .php files caused wrong behaviour of the website (it was a really bad idea).
Commonly advised things of fixing this did not work for me. What I tried:
Adding the following to .htaccess:
<FilesMatch ".(eot|ttf|otf|woff|php)">Header set Access-Control-Allow-Origin "*" </FilesMatch>Added some lines to nginx.conf on the server side, like allowing all php (it was a bad idea:))
location ~ .(js|css|png|jpg|jpeg|gif|ico|html|woff|woff2|ttf|svg|eot|otf|php)$ { add_header "Access-Control-Allow-Origin" "*"; expires 1M; access_log off; add_header Cache-Control "public"; }
Please, advise on how to avoid the CORS policy blocking the admin-ajax.php on a subdomain?