1

I'm already after reviewing and applying solutions from this thread, but with no result, so I'm desperately looking for some new ideas.

Scenario: My app is served on localhost:4200, my backend is served on localhost:5001. In production environments, they are both on same domain (i.e. some.domain.xyz/frontend and some.domain.xyz/backend), so I assume, this shall be fine, but I'm introducing some breaking change so testing it locally is a must-have.

Via middlewere, that is launched for every single request from frontend to backend i'm setting following:

res.cookie('sapAuth', token, { domain: xxx, maxAge: 24 * 60 * 60 * 1000 });

where for xxx I already tried .localhost, bub.localhost, localhost, .local, null, false, ... and not setting it at all (express.js respect this, in Dev tools domain will be empty.

Regardless of my efforts, I'm not being able to force browser to store my cookie. I'm recieving correct response header:

Set-Cookie: sapAuth=<TOKEN>; Max-Age=86400; Domain=<any-of-listed-above-or-not-present-at-all>; Path=/; Expires=Fri, 17 Apr 2020 09:49:33 GMT

But still, inspecting application tab/cookies section, cookie does not show up. Do we have, in A.D. 2020 some effective method to force browser to correctly store cookie on localhost?

Here is the method reference with possible options: Click

Tomas
  • 3,269
  • 3
  • 29
  • 48

0 Answers0