location / {  
    #允许跨域请求的域,*代表所有
    add_header 'Access-Control-Allow-Origin' *;
    #允许带上cookie请求 
    add_header 'Access-Control-Allow-Credentials' 'true';
    #允许请求的方法,比如 GET/POST/PUT/DELETE 
    add_header 'Access-Control-Allow-Methods' *; 
    #允许请求的
    header add_header 'Access-Control-Allow-Headers' *;
    
   #Access-Control-Allow-Methods 是为了防止出现Content-Type is not allowed by Access-Control-Allow-Headers in preflight response.错误:
    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;
    }
}