Get session call failing Safari
Hi, I’ve recently setup better auth with nextjs, using the drizzle adapter and nextCookie plugin. I wrote my own plugin for steam authentication (OpenID 2.0), which seems to be working good.
However, one weird bug I’ve seen is that on safari, the get session call made when the user clicks my sites sign in button throws an error with status 0 and status text as an empty string.
Any idea why this is happening? Thanks!
10 Replies
@bekacru said…
this is casue it can't reach the server. Either base url or you haven't properly forwarded localhost portMy baseURL is set properly, and I’m using the nextjs dev server url. But this is happening deployed too. https://rust.directory
Rust Directory
Your go-to resource for staying ahead in rust.
Seems like if I make a manual client action it skips the get-session route and works

Where does the get-session call come from? is it some autoamic thing all client action that are inferred will call and do something with?
Maybe this is why from ai

does
authClient.getSession
work
also what error does it show in the consoleError is error code 0 status text empty string
I haven’t tried get session but I think it works
I’m away from computer for a bit, can check when I’m home too
Ok so @bekacru - I got a few questions for you:
The plugin has two endpoints. One is
/sign-in/steam
and the other is /steam/callback
.
To show the session status in my ui, I have a component using the authClient.useSession()
react hook. When the user is signed out, the button click will call authClient.signIn.steam()
and then take the response (which contains a steam URL) and redirect to it. When the user is signed in, the button click will call authClient.signOut()
. That is everything happening on the client side.
1. For sign in, the first thing that happens is the code in the plugin endpoint for /sign-in/steam
. At the moment, it always generates a url using Open ID 2.0 and returns that in a JSON response. It seems like get-session
is automatically called after the endpoint is completed. See screenshot for order. What is the purpose of this call, and why do you think it might only be failing on safari?
2. If the ui is not always in sync with session state, and the user tries to sign in again (when they already are), the plugin (at the moment) will still run the endpoint and generate a url for the user to go sign in at. Ideally we just update the ui and get the existing session. Should the change required for this live in the plugin or is the dev using the plugin responsible to handle that in their ui code?
3. Same question as number two, but for sign out ^
4. Since email is required in better-auth, I am just using a placeholder <steam-id>@example.com
email when setting up users, but do you have any better/recommended way to handle this?
Thank you!
@Gamers pinging you here since I know you were interested