Next.js Discord

Discord Forum

Issue with settings cookies

Unanswered
Forest bachac posted this in #help-forum
Open in Discord
Avatar
Forest bachacOP
Currently, I am having an issue with setting cookies when testing locally. I am testing with postman, and it seems no cookies are returned.

Code:
 await createSession(config, username);
return Success("Logged in successfully!");


createSession:
export async function createSession(...){
...

return cookies().set({
      name: config.cookieName,
      value: sealedSecret,
      expires: config.cookieExpiration,
      // secure: config.secure,
      path: "/",
    });

...
}


The return value of this function is

ResponseCookies {
  _parsed: Map(1) {
    'NEXT_AUTHENTICATOR_COOKIE' => {
      name: 'NEXT_AUTHENTICATOR_COOKIE',
      value: '....removed....',
      expires: 1970-01-08T00:00:00.000Z,
      path: '/'
    }
  },
  _headers: HeadersList {
    cookies: [
      'NEXT_AUTHENTICATOR_COOKIE=........removed; Path=/; Expires=Thu, 08 Jan 1970 00:00:00 GMT'
    ],
    [Symbol(headers map)]: Map(1) { 'set-cookie' => [Object] },
    [Symbol(headers map sorted)]: null
  }
}

0 Replies