Dynamic Redirect on SvelteKit Multi-tenant App

Hey! We're building a multi-tenant app so I'm trying to redirect the user to the appropriate custom domain (and/or subdomain) after signing in. For context imagine Substack or beehiiv. I'm trying to sign in the users of our tenants into the tenant's app they launched through us. I tried using the code below to redirect the user to tenant's subdomain. But it's still redirecting me to the KINDE_REDIRECT_URL set in the .env I tried changing the KINDE_REDIRECT_URL to subdomain.localhost:5175 and it worked as expected.
<a
href="/api/auth/login?post_login_redirect_url=/subdomain.localhost:5175/api/auth/kinde_callback"
>
<button>Sign in</button>
</a>
<a
href="/api/auth/login?post_login_redirect_url=/subdomain.localhost:5175/api/auth/kinde_callback"
>
<button>Sign in</button>
</a>
How do I make it dynamic? Also, currently, Tenant Organizations have their employees as members. Should I also put their Users on signup in their organizations and give them a subscriber role? Or track that separately? Thank you for your help!
1 Reply
TimidTuna
TimidTunaOP3w ago
Thank you for the quick answer Sam! I already have the dynamic callback URL added to the kinde application. My issue is that I can't define the callback inside my code. The code above didn't work so I'm not sure how to send the user to the subdomain they signed in from even if it's part of the allowed callback urls. Organization Structure So, are you saying I should add the users to the orgnizations as well? Or just stick to the employees? Users access the organizations content, while employees access the admin dashboard. They're two different applications under the same organization. KINDE_SITE_URL was never mentioned in the SvelteKit quickstart. Should I add that to the .env? Bumping this to see if anyone can help.
Want results from more Discord servers?
Add your server