server {
set $cors '';
if ($http_origin ~* "^http://deomain01$") {
set $cors $http_origin;
}
if ($http_origin ~* "^http://deomain02$") {
set $cors $http_origin;
}
if ($http_origin ~* "^http://deomain03$") {
set $cors $http_origin;
}
location /live {
...
add_header 'Access-Control-Allow-Origin' '$cors';
#不带cookie请求,设置为false
add_header 'Access-Control-Allow-Credentials' 'true';
# 为预检请求加的header,允许跨域的方法
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE';
#为预检请求加的header,允许跨域使用的请求头
add_header 'Access-Control-Allow-Headers' '*';
}