Better Auth

BA

Better Auth

Join the community to ask questions about Better Auth and get answers from other members.

Join

bug-reports

help

getSession causing error: "Cannot read properties of undefined (reading 'validate')"

Hey, I'm trying to build my auth on my hono backend but I'm getting an error in my middleware when getSession() is called. I was able to debug it and found out that when calling the getSession() function some kind of TypeError happens in the context (see screenshot). Just for clarification: I needed to initialize my better-auth instance via a function so I could pass the Cloudflare workers env bindings into my better-auth instance, as with CF workers it's not possible to access the process envs....
No description

user.findFirst and session.findFirst being run too many times

Is the queries user.findFirst and session.findFirst being run to many times normal?
No description

[RangeError: Too many properties to enumerate]

When i try to get session, via the /api/auth/get-session or via the getSessionCookie helper, i always got a 500 error with "[RangeError: Too many properties to enumerate]", without any others details. If you have some ideas to solve it, it would be a pleasure thx...

How to seed users?

I want to seed some users, and I have a json with user names, emails, passwords. this is going to be a backend script that I run manually. I wonder whats the best way, currently all failing. tired await authClient.admin.createUser, and that is failing, I guess because it only works if the users who runs this is an admin user. and at this stage i'm running this as a script, with no user. also tried await auth.api.createUser , and that also failed with status 'unauthorized'. any idea?...

Can i setup two separate auth config in single project

is it possble to have separate auth config for an single projects separate user base...

Add current Stripe plan to user object

Hello, thanks for the awesome Stripe plugin. I was wondering if it is possible to include the Stripe plan which the user is subscribed to on the user object. This would look like this: User = { id: string; [...]...

Vercel Deploy Problems - Cookies not detected?

I just deployed my app to vercel and m ycookies are no longer detected? I sign in e.g. with a. magic link, i see my cookies in the application but i dont get redirected or whatever When i run it locally i do get redirected, only difference is one is deployed on vercel and the other isnt...

Broken auto sign in?

Hey! I have auto sign in enabled in emailAndPassword. But after signing in, nothing gets auto signed in. Is there another thing that has to be enabled or am I missing something? I am signing up in sever, but nothing reflects on client side, not even after refresh....
No description

Azure B2C vs B2B

Is Azure B2C flow supported somehow? I want to pass my custom policies, but it seems https://www.better-auth.com/docs/authentication/microsoft has no parameter for that. The URL opened by BetterAuth is https://login.microsoftonline.com..., but B2C opens https://smthg.b2clogin.com/smthg.onmicrosoft.com/mypolicy/......

How to secure my socket.io server

How to check session in socket.io server note: My realtime server is a separate server from the authentication server....

Error 400: redirect_uri_mismatch

You can't sign in to this app because it doesn't comply with Google's OAuth 2.0 policy. If you're the app developer, register the redirect URI in the Google Cloud Console. Request details: redirect_uri=...

Payload Request shows email and Password

Why is the email and password visible in the Payload request as seen below: {"email":"[email protected]","password":"XX3PAgX7cb9SUGk","name":"Testing","callbackURL":"/"} This doesn't seem secure. What can be done to not have this happen?...
No description

Optional accountId table?

Hey, first of all i love better-auth, good work guys. While going through the documentation, I came across the account table schema and noticed that the accountId (for OAuth) is marked as optional (LINK). I tried searching the GitHub repo with some Ctrl+F action, but unfortunately, I couldn’t find the answer I was looking for. Is it possible to skip creating the accountId field altogether for discord provider or i have to use generic oauth to manipulate the write?...

Generate sessions for integration tests

Hey! We are using email OTP for our auth and want a way to generate sessions for our integration tests. I couldn't find a way to by-pass the email OTP step and get a session nor was I able to specify a specific OTP to be generated in test that I can then verify. Any recommendation about how should I handle this?...

ERROR [Better Auth]: State Mismatch. Verification not found

Hey! I am getting the the callback error screen for Google (/api/auth/error?error=please_restart_the_process) in a couple situations: - If a user is authenticated on a mobile device using Google Chrome and hits the "Desktop site" option in the Chrome page settings - A user is goes through the sign in flow with Google, selects their Google account, is authenticated successfully, but then hits the back button to go back to the Google account select screen (https://accounts.google.com/o/oauth2/auth/oauthchooseaccount?), and then selects the same Google account. ...
No description

Hono dosen't set cookies, so session returns Null

As you can see when I get mu session from the browser there is a session. Once I call the endpoint in nextjs using betterFetch or fetch the session returns correctly but in the server It dosent work as expected
No description

Maintaining session in a webview.

I'm building an expo app with a nextjs companion app. There are some components that are not available in the react native world and I'm consuming them through a web view. The page that is consumed uses client and server side trpc calls to fetch data/ mutate. Is it possible for me to maintain the session from the expo side inside the nextjs page? On expo i have this ```
const cookies = authClient.getCookie(); const newSource = { headers: { Cookie: cookies },...

OAuthProxy with branched database

I have the following config: ```ts export const auth = betterAuth({ database: drizzleAdapter(db, {...

Handle check email verified

How do you handle the check if the account is already verified? I cannot access this data in the middleware and I am redirecting after the user navigated to a specific page which feels super off. Is there any better way?

Email verification

When signing in with the requiredEmailVerification option on, if the user didn't verify his email address yet, a verification email is automatically sent. This means that the user could spam the sign-in button and/or route Is there any way to prevent that? I guess I could define a custom ratelimit for the sign-in route, as shown here: https://www.better-auth.com/docs/concepts/rate-limit#rate-limit-window but it's not really what I'm looking for. I don't want to ratelimit the route, I just want a cooldown on the verification email...
Solution:
I ended up doing exactly that, creating a new column in my db. This is what is looks like: ```tsx const throwInvalidCredsError = (isEmail: boolean) => {...