Hi, i try to use supertokens on nuxtjs with nuxt-a...
# support-questions
j
Hi, i try to use supertokens on nuxtjs with nuxt-auth. i have write a custom scheme extends cookies scheme. The question is, can i use "sIRTFrontend" to determine whether the session is alive on the middleware checking?
r
Hey
You can use sIdRefresh cookie for that
Why do you need to do a mapping though?
j
i have tried to use "doesSessionExist" on the middleware checking, but nuxt-auth scheme check function is synchronous.. so the workaround i can think of is checking the cookies existence for session check.
r
Is this middleware running on the backend or frontend?
j
frontend with SSR
r
So its running on the server?
Or on both?
j
both
r
Hmm. So that’s tricky
Cause there are different ways to check if a session exists if it’s on the frontend vs backend
What are the values for apiDomain and websiteDomain that you have set?
j
my api is nestjs, apiDomain is http://localhost:9000
r
I see. So your website domain is different then
j
frontend is Nuxt, websiteDomain is http://localhost:3000
r
In that case, you can’t check for if a session exists on the web server. You can only do that on the client side
j
um, yes. I have tried to use "sIdRefresh" on the checking, but HttpOnly cookies is not accessible via JS
r
Yes. That’s not gonna work on the client side. On the client side, you should check that sIRTFrontend exists and it’s value is != “remove”
j
oic
r
But it’s better to just use the doesSessionExist function. It also takes into account missing cookies (since frontend set cookies get cleared on safari every 7 days)
j
yes, i want to. but the logic on nuxt-auth to check cookies is using sync function which i cannot rewrite it to async function to call doesSessionExist
r
Maybe don’t use that function of nuxt-auth at all? I’m not sure. Not too familiar with nuxt-auth 😅
j
it's okay, this logic works for me.
14 Views