Better Auth

BA

Better Auth

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

Join

bug-reports

help

Allow setting hostname for redirectUri

Hey, when better-auth is deployed in a k8s cluster and it gets assigned an origin from ClusterDNS, it constructs a redirectUri like this: http://auth.auth.svc.cluster.local:3000/auth/callback/google I am able to just overwrite the redirectUri, but it would be cool if I could just set the origin of the server thats reachable from outside the cluster. The code change for this should be here I guess: https://github.com/better-auth/better-auth/blob/81ab90865f3e62f760e3d0b470a8ecbb3896e168/packages/better-auth/src/api/routes/callback.ts#L98...
Solution:
baseURL exists, whoops. Maybe this should be added to the production docs as a troubleshooting section

Property 'teams' does not exist on type 'Prettify<{ id: string; name: string; createdAt: Date; ...

I updated the better-auth libary now my types does not work, teams seams like not exist in my types, which should work. Property 'teams' does not exist on type 'Prettify<{ id: string; name: string; createdAt: Date; slug: string; metadata?: any; logo?: string | null | undefined; } & { members: ({ id: string; createdAt: Date; userId: string; organizationId: string; role: string; teamId?: string | undefined; } & { ...; })[]; invitations: { ...; }[]; }>'.ts(2339) ...

Handling required extra fields with Google oauth

I have a field on my db that comes from the user form and I need to assign that value to the user entry on google signin/signup How is this possible to do? I cant find it in the docs...

session null in nextjs route handler

I know auth and sessions is working because it I can log in and out with no problem. My server functions are able to get sessions but whenever I try and get the session from a route handler it's null This same function is used throughout my app and works everywhere except route handlers ```...

Some users are randomly signed out and can only sign in again after waiting for some hours

Hey! I am experiencing a weird behavior where some users are signed out of my app and need to wait hours to sign in again. I use phone number with OTP as the sign-in method. Their session token is not set to expire before several days. Has someone experienced something similar and found a fix for it?

How to create /api/auth/*all.ts file in windows

creating file with * is not allowed, so how to use auth with solid start then??🤓
No description

Double password check

We're working on the "v2" of one of our apps and we're migrating from an old express with nothing more than a 'login' route to nextjs with better-auth. The actual users are saved with a sha256 and we don't want to keep that (ofc). Asking all of our users to reset their password is not really an option, so we were wondering if we could achieve something like keeping the old password in our database in a "old_password" column, when a user try to connect and if this column is not empty, we verify if the password is correct then, update the (scrypt) user password and unset the old_password. Do you have any idea on how I could do that ? One idea was in the "verify" function but only the hash is passed and not the email. Maybe a "before hook" ?...
Solution:
```ts hooks: { before: createAuthMiddleware(async ctx => { if (ctx.path !== '/sign-in/email') { return...

Email verification not working as I would expect

I have a pretty simple BetterAuth set up. I am just trying to do a simple emailSignUp with email verification flow. I followed the docs page on email sign up. ``` export const auth = betterAuth({ emailVerification: {...
No description

Social login bug

I am using social login (specifically Microsoft) and clicking login makes a POST request to /api/auth/sign-in/social then redirects me to http://localhost:3000/login (with just a ?) and then redirects me to http://localhost:3000/login and doesnt sign me in. If I spam click it, it eventually redirects me to the social provider but I have no idea why this is happening.

How to get Twitter username by useSession?

i config like image but not work
No description

mongodbAdapter isn't compatible with jwt() plugin?

I've been trying to generate jwt using the mongodbAdapter, but just doesn't work, what's the issue here? setting up with mongodbAdapter was also quite difficult, and why is it so opinionated? I couldn't even change the collection names or have them as per my liking,

"522 Connection timeout" when fetching session with getSession during SSR [Cloudflare Worker]

Keep getting this error on cloudflare. What's weird it's only happening when I'm trying to sign in with any social provider. For email/password it works fine. No issues locally too....

How do you add 2fa to a user account created using social sign in?

How do you do 2fa and change password for accounts created using social sign in? There are no passwords associated with the account. so is there a way to set new password for these accounts? Thank you....

Getting auth data in react server component when auth is handled by express backend

is there a good way to be able to call the backend auth from react server component in a project where the auth is implemented using a separate express backend?

Create user with ban to enable by admin

Hey i am looking for a way to create new users that should be banned / disabled until a admin enable them. i already installed the admin plugin. Best Marcel...

Backend Auth + Frontend Framework Tutorial

Looking for a good tutorial on how to use Better-Auth in an architecture where it's on a server (i.e. Express) at api.myapp.com And the frontend (i.e. next.js/react) at www.myapp.com does not have access to the database, it just calls the Better-Auth we setup on the above mentioned server, using a Better-Auth client. Feels like this should be well documented example in the docs, but I cannot find much about this architecture....

How to use Token

Hi, i use OpenAPI plugin and when i go on this url "https://localhost:3000/api/auth/reference" i got a lot of url i can use, when i sign-in i have this result (1 screen), but when i want to use url with token needed, he give me an error (2nd screen)
No description

Issue with Stripe Webhook URL Configuration in Microservices Architecture

I am currently hosting my API using a microservices architecture. The base URL for this particular service is:
http://api.attendancekeeper.net/betterauth
In my auth.ts configuration, I have set the basePath to:...
No description

api key update throws date error

For some reason the API Key update a.k.a auth.api.updateApiKey throws a date error This is the code: ```ts...
No description

How to set ExpireAt for user

Hello Better Auth community 😆 Im trying to add a datetime to set an expire date for certain users. I was able to cancel a creation of new session in sign-in but having trouble canceling an update of a session. ...