Next.js Discord

Discord Forum

Cross subdomain cookies nextauth

Unanswered
Northeast Congo Lion posted this in #help-forum
Open in Discord
Northeast Congo LionOP
i have docs.domain.com & panel.domain.com. If a user logs into panel, I need them to be able to access docs - how can I do this?

3 Replies

Northeast Congo LionOP
Do I need to use same next auth secret?
i believe that you can use the [domain attribute in cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#domain_attribute) to do the cross-subdomain, but ill check for nextauth...
Same root domain, different subdomains: If you use NextAuth.js on a website with a different subdomain than the rest of your website (e.g. auth.example.com vs. www.example.com) you will need to set a custom cookie domain policy for the Session Token cookie. (See also: [Cookies](https://next-auth.js.org/configuration/options#cookies)).

from: https://next-auth.js.org/faq#compatibility (under "Can session generated by NextAuth.js be used by another website?")