Hey I have a issue with my capacitor ios app again...
# support-questions
c
Hey I have a issue with my capacitor ios app again. Here is the debug log from the phone. It logs in normally and cannot hold session somehow. Any ideas?
r
Hey! Do you mean refresh doesn’t work? Or app restart logs out the user? Or something else?
c
So i log in ... that works.. after that I check with doesSessionExist() on every router navigation if the session exists
if not i redirect to the login page
I already had the issue some time ago but there i added a cookiehandler and it worked
r
So here doesSessionExist() returns false?
c
After logging in this is the content from localStorage
VELVET_FRONTEND_COOKIES    ["sIRTFrontend=remove;expires=Fri, 31 Dec 9999 23:59:59 GMT;path=/;samesite=lax","sFrontToken=;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/;samesite=lax"]
Probably wrong right?
yes
r
Yea. The content implies that no session exists.
Are you calling the api using axios?
I mean the login API
c
no i use fetch
r
Hmm.
And supertokens init is called before making the request?
c
Yes in my main.ts file
SuperTokens.init({ enableDebugLogs: true, apiDomain: HOST_URL, apiBasePath: "/auth", cookieHandler: getCookieHandler, // windowHandler: getWindowHandler, // Did the trick for electron // sessionScope: "localhost:5000", });
Like that (HOST_URL: http://192.168.198.34:5000)
I already tried with the window handler but that should only be necessary with electron, right?
without the slash... discord added it
is there a new version for the cookieHandler? I got it from the electron example
r
No. The cookie handler is still the same.
Are any of the functions in your cookie handler being called when you call the fetch API?
c
I will take a look
Could you send me the cookieHandler example again?
c
Yes they get called a bunch of times
r
Can you print out the input to the functions and paste it here?
c
yes ... wait a second
is that ok?
Or do you want it together with the debug output?
just in case
r
So it seems that it’s being set properly initially, and then right after, the session is removed
c
yes so akward
r
Can u check if the signOut api is called in the backend by any chance?
Or you can enable debug log on the backend and show me the output of that too when calling this API
c
do i need to specify the cookiDomain?
just a second...
r
You don’t need to specify the cookieDomain
Right. So iOS is not sending the cookies to the backend and then subsequent requests are failing with an unauthorised error
c
yes.... i dont understand why the cookies get deleted
r
iOS doesn’t send the cookies at all
What’s the apiDomian that you are using? And what’s the websiteDomain value?
c
oh ok and because the refresh fails it delets the locally
r
On the frontend side
c
You mean the backend init?
r
On the frontend init
What’s the apiDomain?
c
r
Hmm. So on the backend, you should make it that as well.
c
i set the websiteDomain to http://localhost:3000 ... is that the issue?
r
And u need to use https for the apiDomian, otherwise things won’t work.
Ok so basically, you need to set cookieSameSite as none on the backend, and use https to query the backend
c
okay so https is the issue here?
r
Well, partly. You also need to set cookieSameSite to none on the backend
c
okay... i will check that
thanks for your help
just
cookieSameSite:"none"
in the init function?
r
In the session.init part
And you need to use https for the apiDomain and whilst querying the apiDomain as well
c
you mean EmailPassword.init() ?
r
Session.init on the backend
c
okay
But isnt the EmailPassword Recipe used for my login ?
I think i only used the Session Recipe for requesting a jwt token
r
EmailPassword creates a session using the Session recipe
And this is a setting related to the session. Hence in session.init
Hope this helps 🙂
c
Ah okay thank you
I will try that tomorrow
3 Views