Solving the problem of double Cross-Domain in Nginx
The 'Access-Control-Allow-Origin' header contains multiple values ', ' but only one is allowed error.
Server side allows cross-domain
location / {
add_header 'Access-Control-Allow-Origin' $http_origin;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,web-token,app-token,Authorization,Accept,Origin,Keep-Alive,User-Agent,X-Mx-ReqToken,X-Data-Type,X-Auth-Token,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
error handling
Look at the error prompt above, contains multiple values "*" means that two cross-domain settings have been set. On our side, I have set cross-domain processing in nginx, and development has also set cross-domain processing in the program, but only one is allowed. Remove any of them. If the server is set to allow cross-domain, there is no need to set cross-domain in the Nginx proxy.