1
votes

When I make requests to a server with Postman(an api service), chrome automatically makes a cookie. However, when I make a request with my nodejs server, the cookie is not being made even thought the request is successful.

  //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);
  });

The response header is

{"date":"Tue, 23 Feb 2016 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"}

1

1 Answers

1
votes

Pass { jar: true } in your request options.

From the documentation:

jar - If true, remember cookies for future use (or define your custom cookie jar; see examples section)