Next.js Discord

Discord Forum

next-auth sessionToken domain not set

Unanswered
landoooooo posted this in #help-forum
Open in Discord
I'm trying to get authentication to work across multiple domain and this was the suggested workflow I've found. The only issue is that even though I'm setting domain as .website.app the actual cookie in the browser is displayed as www.website.app which doesn't allow authentication on my subdomains.

Any help would be greatly appreciated!
cookies: {
  sessionToken: {
    name:
      process.env.NODE_ENV === "production"
        ? `__Secure-next-auth.session-token`
        : `next-auth.session-token`,
    options: {
      httpOnly: true,
      sameSite: "lax",
      path: "/",
      secure: true,
      domain: ".website.app",
    },
  },
}

1 Reply

Additionally when I manually update the __Secure-next-auth.session-token cookie domain in the browser to .website.app it works fine in the subdomain as expected. I just need it to be set as I originally intend.