【发布时间】:2016-06-05 20:50:42
【问题描述】:
当我使用 Postman(一种 api 服务)向服务器发出请求时,chrome 会自动创建一个 cookie。但是,当我向我的 nodejs 服务器发出请求时,即使请求成功,也不会发出 cookie。
//Headers
var options = {
method: 'GET'
};
options.headers = {};
options.headers.Authorization = auth;
options.url = urlm;
console.log(options);
request(options, function(error,response,body) {
res.status(200).send(response.headers);
});
响应头是
{"date":"2016 年 2 月 23 日星期二 20:06:57 GMT","server":"Jetty(9.2.1.v20140609)","x-csrf-header":"X-CSRF- TOKEN","expires":"Thu, 01 Jan 1970 00:00:00 GMT","x-csrf-token":"xxxxxxxxxxx","cache-control":"no-store","content-type" :"audio/mpeg","set-cookie":["JSESSIONID=uiqwnksadbohqjkq675d;Path=/;HttpOnly"],"connection":"close","transfer-encoding":"chunked"}
【问题讨论】: