1. 程式人生 > >nginx 實現跨域

nginx 實現跨域

session add pre err pan gpo true cookie tro

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(){       } });

nginx 實現跨域