0

I am using apollo graphql on backend side and using cookie authentication method. But when I set cookie on backend side cookie was in Set-Cookie header but doesn't showed in Browser->application ->cookies

response.cookie('tokens', token, {
        httpOnly: true,
        secure: true, //process.env.NODE_ENV === 'production',
        sameSite: true,
        expires: new Date(Date.now() + 1000 * 60 * 60 * 24),
      });

Returned response: Response image

Nothing here. Application cookies

Tried many advices but nothing worked for me.

1 Answers1

0

You can set the cookie by

        context.setCookies.push({
          name: "token",
          value: result.token,
          options: {
              domain:'DOMAIN_NAME',
              httpOnly: true,
              maxAge: 36000,
              secure: 'none',
              path: '/',
              sameSite:'None'
          }
      });
  • Remember to make sure domain name is your Server host name,
  • no need of protocol in domain, i.e., https
  • set samesite to none

by this, I was able to set the cookie and it was set in application folder in developers tool

  • you cannot test this in incognito,
  • in network tab, in the rest call, in cookie section, you can confirm if all attribute is set correct or not.