'Nginx Cross-origin fails when both cross-origin and cache policies are used at the same time
Below is my nginx configuration file.
server {
listen 80;
server_name test.abc.com;
location / {
if ($request_filename ~* .*\.(?:htm|html)$) {
add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
}
add_header 'Access-Control-Allow-Origin' 'https://test.abc.com';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Credentials' true;
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
if ($request_method = 'OPTIONS') {
return 204;
}
root /etc/nginx/html/test/;
index index.html;
try_files $uri $uri/ /index.html;
}
}
But the cross-domain related configuration is lost in the response header.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
