#Next Auth Multi Tenant Site

18 messages · Page 1 of 1 (latest)

full bridge
#

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?

Vercel Documentation

Learn how to create and deploy a full-stack application with multi-tenancy and custom domain support using Next.js App Router, Vercel Postgres, and the Vercel Domains API.r

weary portalBOT
#

🔎 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)
full bridge
#

^

wintry snow
full bridge
#

Do you know any examples / tutorials on this?

full bridge
#

Yes I have nextauth setup for the dashboard app though for users individual sites / domains, im not sure where to start?

full bridge
#

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?

full bridge
#

Anyone got any ideas?

full bridge
#

Everybody avoiding this topic 👀

rocky inlet
#

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

slender mural
#

For the sake of brevity & learning let’s assume tenants company name

rocky inlet
#

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)

full bridge
#

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