cooke domain sharing
# bot-training
r
I have a little bit of a tricky situation. I want to authenticate users using my express js api for a Next JS application. However, I want to use Next JS's server side rendering functionality to fetch user data and render the page. When I try to fetch the /myinfo route to get the user info, it can't get the cookies because the site and the api are using 2 different domain names. How can I solve this problem?
You can solve this problem by setting the
cookieDomain
property in the SuperTokens initialization object to the parent domain that both the site and the API share. This will allow the cookies to be shared across both domains. Additionally, you can use the
getSession
function in Next JS to get the user session on the server side and use it to fetch user data and render the page.
st-bot-test-case
2 Views