Title
j

JoelC

04/14/2022, 4:18 PM
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

rp

04/14/2022, 4:19 PM
Hey
You can use sIdRefresh cookie for that
Why do you need to do a mapping though?
j

JoelC

04/14/2022, 4:28 PM
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

rp

04/14/2022, 4:28 PM
Is this middleware running on the backend or frontend?
j

JoelC

04/14/2022, 4:29 PM
frontend with SSR
r

rp

04/14/2022, 4:30 PM
So its running on the server?
Or on both?
j

JoelC

04/14/2022, 4:31 PM
both
r

rp

04/14/2022, 4:32 PM
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

JoelC

04/14/2022, 4:34 PM
my api is nestjs, apiDomain is http://localhost:9000
r

rp

04/14/2022, 4:35 PM
I see. So your website domain is different then
j

JoelC

04/14/2022, 4:35 PM
frontend is Nuxt, websiteDomain is http://localhost:3000
r

rp

04/14/2022, 4:35 PM
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

JoelC

04/14/2022, 4:39 PM
um, yes. I have tried to use "sIdRefresh" on the checking, but HttpOnly cookies is not accessible via JS
r

rp

04/14/2022, 4:40 PM
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

JoelC

04/14/2022, 4:40 PM
oic
r

rp

04/14/2022, 4:40 PM
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

JoelC

04/14/2022, 4:46 PM
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

rp

04/14/2022, 4:51 PM
Maybe don’t use that function of nuxt-auth at all? I’m not sure. Not too familiar with nuxt-auth 😅
j

JoelC

04/14/2022, 4:53 PM
it's okay, this logic works for me.