nginx 实现跨域

nginx 添加头部跨域。

location / {
    add_header 'Access-Control-Allow-Origin' '*'; //允许的域
    add_header 'Access-Control-Allow-Credentials' 'true';  //允许cookie
}

前端ajax session id 不一致问题:

$.ajax({
    url:url,
    xhrFields: {
      withCredentials: true
      },
    crossDomain: true,
    success:function(result){
      alert(“test”);
      },
    error:function(){
      }
});
原文地址:https://www.cnblogs.com/rongkang/p/7997486.html