Auto logout
Hi,
Im using nextjs + mongodb and Redis for caching.
But when I update the site, some users getting logged out. and some was saying that it takes a few minutes to login again.
18 Replies
I think the problem is with secondary storage
if it didn't find the data in secondary storage, it doesn't check on the db
@Ping sorry for pinging but I really need to fix this fast
Few minutes? Interesting.
I'm pretty sure once you enable secondary stroage that it will default certain tables to that secondary storage DB. Your primary DB isn't a backup. So if it can't find the session in your Redis DB, it wouldn't search your primary.
Was it that you recently enabled secondary storage? And you had some sessions on primary db previously?
no, Im using secondary storage from the beginning, but I did switch to a new server
can I make it so, if the session is not available on redis it will search the primary db?
No I don't think so, unfortunately. Though it's not a bad idea for a feature.
I hope you will add it in the future
we should allow this if
session.storeSessionInDatabase
is set to true. Will ping you when it's changedok thanks
check
v1.2.6-beta.1
it still not working
in development If i add the secondary storage and don't provide the the redis url (then it will return null), and try to login, my account is not showing, it still only checking from secondary storage and if I remove secondary storage, it works fine
make sure to enable
session.storeSessionInDatabase
it's working now
thanks
sorry but im using an electron app,
im getting this error after
client.signIn.social
reading from http://localhost:3939/oauth/callback?state=s2pyqkoffSwCSX_lJhhvjropJ3uxbMu9&code=4%2F0AQSTgQFIub5p--00iY-ejLmokPBa-0rVHAY_p2pFQH1G3CxAfmribkZemhaAAfPsSBrG1A&scope=email+profile+openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email&authuser=0&prompt=consent
I added http://localhost:3939/
in the trustedOrigins
but still not working
see the server logs. this has to do with verification request to the provider returning an error.
is there any way to ignore this error?
because in electron js, I need to change the redirect url to
http://localhost:3939/oauth/callback
to redirect back from the browser to app
you should provide
http://localhost:3939/oauth/callback
to callbackURL
when you call signIn.social
but then there is not state in the callback url:
2025-03-27T09:51:21.255Z ERROR [Better Auth]: State not found undefined
it redirects to to http://localhost:3939/oauth/callback
but with the data or state with itcalling
signIn.social
should return you a url in the response.sorry, I don't understand what you meant. this is how im doing it
my app works like, if
accounts.google.com
opens in the app, it opens the url in the users browser where they have their accounts, after they select their account they redirects to http://localhost:3939/oauth/callback
that is a server created from the electron app, and when user redirects to this url, the app opens the api route ${DOMAIN}/api/auth/callback/google
for signiin with the data
is there any way to get the session data from the site?