rp_st
02/20/2022, 12:43 PMrp_st
02/20/2022, 12:44 PMmrserif
02/20/2022, 12:46 PMmrserif
02/20/2022, 12:46 PMmrserif
02/20/2022, 12:47 PMsupertokens.init({
framework: "express",
supertokens: {
// These are the connection details of the app you created on supertokens.com
connectionURI: process.env.SUPERTOKENS_URL,
apiKey: process.env.SUPERTOKENS_API_KEY,
},
appInfo: {
// learn more about this on https://supertokens.com/docs/session/appinfo
appName: "Serif Health",
apiDomain: process.env.BACKEND_URL,
websiteDomain: process.env.FRONTEND_URL,
apiBasePath: "/auth",
websiteBasePath: "/",
},
recipeList: [
EmailPassword.init(), // initializes signin / sign up features
Session.init() // initializes session features
]
});
mrserif
02/20/2022, 12:48 PMmrserif
02/20/2022, 12:48 PMrp_st
02/20/2022, 12:48 PMBACKEND_URL
and FRONTEND_URL
*.vercel.app in that case?mrserif
02/20/2022, 12:49 PMmrserif
02/20/2022, 12:49 PMrp_st
02/20/2022, 1:08 PMserifhealth.vercel.app
.
If you want to have just one process though, it's a little messy, but possible. The purpose of websiteDomain
is to generate reset password links and email verification links + determine the settings for cookies.
So you can emulate multiple values for this by providing callbacks for generating a reset password link (with a different link) and an email verification link (with a different link) + setting cookie settings manually (you can keep the websiteDomain
to serifhealth.com in this case).
1) generating a password reset link:
Provide the getResetPasswordURL
URL as shown here: https://supertokens.com/docs/thirdpartyemailpassword/common-customizations/reset-password/embed-in-page#step-a-on-the-backend to generate a link for *.vercel.app in case the request is from the staging env.
2) generating an email verification link:
Provide the getEmailVerificationURL
URL as shown below:
https://supertokens.com/docs/thirdpartyemailpassword/common-customizations/email-verification/embed-in-page#step-a-on-the-backend to generate a link for *.vercel.app in case the request is from the staging env.
3) cookie setting:
I assume that in prod, the API layer is *.serifhealth.com, but the website is on *.vercel.app. This in turn means that the cookie setting will have to have:
- sameSite: none
- secure: true
Both of these can be set as shown here: https://supertokens.com/docs/thirdpartyemailpassword/common-customizations/sessions/same-site-cookie and https://supertokens.com/docs/thirdpartyemailpassword/common-customizations/sessions/cookies-and-https
Also, they will only work on browsers which support third party cookies (or if you enable that on browsers like safari)
I'm not sure how changing these will impact the cookie behaviour in prod, but I suspect that it shouldn't. However, if you want the cookie settings to be unchanged in prod, you would need to intercept the response and change the Set-Cookie
header values for the cookies on the fly based on which domain queried it.
Lmk what works for you and if you would like more info 🙂rp_st
02/20/2022, 1:08 PMmrserif
02/20/2022, 1:33 PMmrserif
02/20/2022, 1:34 PMrp_st
02/20/2022, 1:35 PMSuperTokens is an open source authentication solution offering features like: Different types of login: Email / password, Passwordless (OTP or Magic link based).
Powered by