Hello! Im interested in building a "multi tenant" application with nextjs. I've seen this post: https://vercel.com/guides/nextjs-multi-tenant-application though im wondering how I would add authentication / login to the individual sites (the sites have its own users)? Would this be something possible with next auth?
#Next Auth Multi Tenant Site
18 messages · Page 1 of 1 (latest)
🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord
🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in <id:customize>
✅ You can mark a message as the answer for your post with `Right click -> Apps -> Mark Solution`
(if you don't see the option, try refreshing Discord with Ctrl + R)
^
yeah you can, that's definitely possible with next auth
Do you know any examples / tutorials on this?
Yes I have nextauth setup for the dashboard app though for users individual sites / domains, im not sure where to start?
So in theory I would need next auth on the [domain]/api/auth but how would I handle the credentials / callback urls?
or could I make something work on like a main "auth.MYDOMAIN.com" that the individual sites get the session from?
Anyone got any ideas?
Everybody avoiding this topic 👀
Are you wanting the URL to be reflecting the tenants company name ?
As apposed to when a user logs in, thjey are on app/dashboard?
I'm not entirely sure what you're asking / trying to do
For the sake of brevity & learning let’s assume tenants company name
on login (and probably some middleware to enforce it), redirect user to app/[tenant] where 'tenant' is the tenant's name retrieved from session info ? (coming from the cookie created at login)
Yeah so like the app/dashboard is for managing their [tenant] site which has a login for that company. Then that companies tenant site has its own set of users for their site
If that makes sense
I do have a solution though im not sure if its a great one
(Discord OAuth)
A company / tenants user clicks on login on the app/[tenant] site which sends them to a discord oauth that redirects to my site auth.MYDOMAIN.com/?redirect={TENANTDOMAIN.COM/api/auth/callback} that then redirects it again to their site which should give the discord oauth user / details