When calling a ajax jquery request across two domanis I get this error
Access to XMLHttpRequest at 'https://xxx' from origin 'https://xxx' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
This is how the nginx conf looks like
location ~ \.php$ {
include /var/ini/nginx/fastcgi.conf;
fastcgi_pass php;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
add_header Access-Control-Allow-Origin '*' always;
}
If I call the URL directly in the browser I get these response headers
access-control-allow-origin: *
cache-control: no-store, no-cache, must-revalidate
content-encoding: gzip
content-type: application/json
date: Tue, 14 Jun 2022 13:30:13 GMT
expires: Thu, 19 Nov 1981 08:52:00 GMT
pragma: no-cache
server: nginx
set-cookie: PHPSESSID=24uu79lr3quljgtjr19a1adqu4; path=/; HttpOnly
vary: Accept-Encoding
If I call the same resource via ajax jquery these are the response headers with HTTP 301
content-length: 162
content-type: text/html
date: Tue, 14 Jun 2022 13:30:22 GMT
location: https://xxx
server: nginx
strict-transport-security: max-age=31536000