angularjs携带cookie跨域请求

B.com下的前端跨域访问A.com下的服务:

客户端:

 return $http.get('http://A.com:8070/micro/sql/run/'+id+'?sql='+sql, {
            withCredentials: true
        });

withCredentials :true;

服务端:

        res.setHeader("Access-Control-Allow-Origin", "http://B.com:8090");
        res.setHeader("Access-Control-Allow-Methods", "*");
        res.setHeader("Access-Control-Max-Age", "3600");
        res.setHeader("Access-Control-Allow-Headers", "DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,SessionToken");
        res.setHeader("Access-Control-Allow-Credentials", "true");

或者使用

$http.jsonp(http://A.com:8070);

 

你可能感兴趣的:(java,angularjs,跨域访问,携带cookie,jsonp)