One login per sub domain
We will demonstrate the changes required for this with an example:
- Customer 1: Let's say that the name of the customer is
abc
. In this case, we want them to login viaabc.example.com/auth
and get redirected to useabc.example.com
after login. - Customer 2: Let's say that the name of the customer is
xyz
. In this case, we want them to login viaxyz.example.com/auth
and get redirected to usexyz.example.com
after login.
Frontend setup:
- Change the
init
function params forabc.example.com
SuperTokens.init({ appInfo: { appName: "YOUR APP NAME", apiDomain: "YOUR API DOMAIN", websiteDomain: "abc.example.com", }, recipeList: [...] });
- Change the
init
function params forxyz.example.com
SuperTokens.init({ appInfo: { appName: "YOUR APP NAME", apiDomain: "YOUR API DOMAIN", websiteDomain: "xyz.example.com", }, recipeList: [...] });
We set different websiteDomain
values per customer.
Backend setup:
- Change the
init
function params in accordance with the frontendsupertokens.init({ appInfo: { appName: "YOUR APP NAME", apiDomain: "YOUR API DOMAIN", websiteDomain: "example.com" }, recipeList: [ EmailPassword.init({ resetPasswordUsingTokenFeature: { getResetPasswordURL: (user) => { let {id, email} = user; // getUserDomain is your implementation let userDomain = await getUserDomain(userId); return `https://${userDomain}.example.com/reset-password`; } }, emailVerificationFeature: { getEmailVerificationURL: (user) => { let {id, email} = user; // getUserDomain is your implementation let userDomain = await getUserDomain(userId); return `https://${userDomain}.example.com/verify-email`; } }, }), Session.init() ] });