How to add subdomain auth flow for a multi tenant app?
I already tried setting the KINDE_COOKIE_DOMAIN=.localhost
Here's my .env
KINDE_CLIENT_ID=
KINDE_CLIENT_SECRET=
KINDE_ISSUER_URL=
KINDE_SITE_URL=http://app.localhost:3000
KINDE_POST_LOGOUT_REDIRECT_URL=http://app.localhost:3000/login
KINDE_POST_LOGIN_REDIRECT_URL=http://app.localhost:3000/login
KINDE_M2M_ID=
KINDE_M2M_SECRET=
KINDE_ORG_CODE=
KINDE_COOKIE_DOMAIN=.localhost
I am using the following for both sign up/login flows from app.localhost and {subdomain}.localhost
import { RegisterLink, LoginLink } from "@kinde-oss/kinde-auth-nextjs/server";
When I removed KINDE_COOKIE_DOMAIN, the app.localhost:300/login works properly, but when I add it, I can't sign in and I get logged out as soon as I register.
3 Replies
Hi @conkyyy,
Thanks for reaching out.
What version of the NextJS SDK are you using?
Also, are you able to explain a bit more about what you are trying to achieve?
Do you want to have authentication for multiple subdomains - e.g. something like
website.yourdomain.com
, app.yourdomain.com
, docs.yourdomain.com
?hoping I can hop on this old thread because im trying to do something similar
here is my .env
I want the user to be able to login from http://localhost:3000 or http://*.localhost:3000 (i.e. http://testing.localhost:3000, http://potato.localhost:3000)
and have the same user
I log in from http://localhost:3000 and i see my user
but when i go to http://testing.localhost:3000 the user is null (also there are no cookies so that makes sense)
not sure how to use the wildcard strategy here im usingNext.js v15 app router
currently I am using nextjs rewrites to access my subdomain not sure if that is related to the issue
currently not using kinde middleware since i just set it up (also not sure if that is a facto)
folder structure for next.js app router if helpful