3

I am using Nodejs as Backend and Angular for front-end, I am trying to use cookies.

I am using the following code to set cookies:

const conf = {
                 signed: true,
                 path: "/",
                 secure: false,
                 maxAge: 60*60*10000000,
                 httpOnly: false,
              };
app.use(cookieParser());
res.cookie('name', 'val', conf);

When I use the same in local server, I can see Cookies being set in Chrome Dev-Tools Application. When I deploy, the cookies are not visible in my angular application. But the cookies are set, I don't know why they are not visible in browser also not accessible by javascript.

When I send a request from angular with withCredentials:true, with a debug statement in node server, console.log(req.headers.cookie) - I get the cookie.

But why the cookie is not showing in Browser.

  • 1
    hey I am having the exact issue... they are set in nodeJS with the next request, but I don't see them in the browser... did you figure it out? Are you using cors? – André May 13 '20 at 16:14
  • i think you are hosting frontend and backend on different platform and browser does not allow to set cross site cookie by default check this discussion https://stackoverflow.com/questions/3342140/cross-domain-cookies – Jagadish Shrestha Dec 25 '22 at 16:42

0 Answers0