I'm currently working on setting up a local environment where I'm attempting to log into a service. In the client side, I'm using the 'request' library, and on the service side, I'm utilizing Express and express-session.
While using Chrome, I encounter the following response headers upon logging in to the service:
FROM: http://app.dev:3000
TO: http://app.dev:4000/login/local
HTTP/1.1 200 OK
X-Powered-By: Express
Access-Control-Allow-Origin: http://app.dev:3000
Vary: Origin, X-HTTP-Method-Override
Access-Control-Allow-Credentials: true
Content-Type: application/json; charset=utf-8
Content-Length: 304
ETag: W/"130-fdQBs605dSVTeEqXEuXrvdcQTLk"
set-cookie: auth=TOKEN; Path=/; Expires=Sun, 25 Jun 2017 01:48:41 GMT
Date: Sat, 24 Jun 2017 13:48:41 GMT
Connection: keep-alive
When I log in using Postman, the cookie is stored correctly. Subsequent requests through Postman include the cookie, and the process works smoothly.
However, when attempting the same request with the npm request
library, the cookie is not saved. Subsequent requests to the backend do not include cookies. An example request to the service after logging in shows that no cookie is sent.