Better Auth

BA

Better Auth

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

Join

bug-reports

help

Trying to revoke a session server-side.

Hello! I have been trying to revoke a session server-side, I figured I could try to use: ```typescript const result = await auth.api.revokeSession({ method: "POST",...
Solution:
If anyone else needs this: - Install the bearer plugin - Create a headers object - Set Authorization: Bearer <token>...

Cross Domain : Receiving null for both data and error while fetching session

I have a nextjs frontend and a hono backend both hosted in ec2 instance through docker. While logging in the cookies are being passed and stored in the browser, but after loging in the user is redirected to dashboard page where i use
const {data,error} = await authClient.getSession({fetchOption : { header : await headers()}})
const {data,error} = await authClient.getSession({fetchOption : { header : await headers()}})
...

how to set cookie after verifiying one-time-token.

hi, i have another desktop client (electron) that authenticates with my remix/react-router v7 server. (this is working fine) With the one-time-token, I am trying to redirect users to my website (frontend of the remix/react-router) so that they can upgrade their plan but they need to be logged on the website. The one-time-token is correctly being verified on redirect, but it doesn't set the cookie on the website correctly. I tried to modify the response headers but the token that is being returned from the one-time-token/verify is not the full token. It's only the first part of it anyone know a way around this to get the full token? I am trying to use an after hook to ctx.setNewSession but that is not workign either for me. ``` export async function action({ request, context }: ActionFunctionArgs) {...

404 on subscription routes

Hey there, I am currently trying to setup stripe with Better Auth, but I am always getting a 404 error when trying to upgrade / create a subscription, even though I should have the correct route setup, if I'm not mistaken
No description

Iโ€™m having trouble getting Google OAuth to work with better-auth in my monorepo (Turborepo) setup

Hereโ€™s whatโ€™s happening: - Email/password login works fine (session cookie is set, user is authenticated). - Google login fails after redirecting back from Google.
- The backend logs show: ...

Drizzle-adapter ignores additional fields when updating entity

Hi - i am using the drizzle-adapter and added an additional field (clubId) to my user-table. But, when i try to update my user (set the clubId) the database-field never gets updated. From what i see in the debug-logs, better-auth recognizes the field but the created sql query just does not include the additional field. ...
No description

Using admin plugin methods on server-side

I've added a user-delete feature on my bot and dashboard. Deleting users manually from the DB doesn't reflect in the bot (It says user is found while re-creating after deleting). admin.removeUser returns "Unauthorized" since I can't pass headers server-side.

Social sign in opens a new tab

Whenever I call authClient.signIn.social(), it opens a new tab. Is there a way to fix it so that it uses the same tab? This is my code: ```ts authClient.signIn.social({...
Solution:
Nevermind. It's an issue with pinned tabs in my browser causing this

Modify members table

Is there a way to add new fields to the members table? The docs points to a way, to remap existing properties to new column names, but couldn't find anything on adding custom fields (like for the users table)...

session always returns null

First post here! Any help/correction would be appreciated!! When i try to get the session using authClient.getSession(), for localhost (backend) I am able to retrieve the sessions details. But when my backend application is deployed on a linode server, session is always null. I noticed that when my application (backend) was running locally the Cookie was present in the request headers and am able to get session data. But when this same application (backend) was hosted on Linode the Cookie was not present in the request headers and session is always null....

Social Auth - Implement Custom Logic after SignIn

So far, I use email and password for authentication. After successful email verification, I create basic user settings which are required to make the app work. ``` ... onEmailVerification: async (user, request) => {...

Polar with existing users

Because better auth creates polar customers on signUp, the already existing users before using Polar plugin will not be created on polar. Should I manually create theses users? What is the best practice?

Only create account

Hello! The application I support has been using auth0 for authentication only since its inception. We already have a users table in our database. We only get the email and if it's been verified from auth0. We're migrating to betterauth and plan to use betterauth the same way to make migration easier. Here's the main scenario we need working to successfully migrate: Given a user has logged into the application using auth0 (username/pass or social sign in - doesn't matter). (This also means they already have a user record in our database)...

SERVER_ERROR: Error: hex string expected, got undefined

So i started migrating from clerk to better auth. the docs are amazing. i love everything about better auth. so i run the migration script. added the accounts and done everything. then i tried logging in from my expo app and got the following error SERVER_ERROR: Error: hex string expected, got undefined at hexToBytes (file:///Users/mac/Desktop/work/GoGain/GoGain-backend/node_modules/@noble/hashes/esm/utils.js:141:15) at Object.verifyPassword [as verify] (file:///Users/mac/Desktop/work/GoGain/GoGain-backend/node_modules/better-auth/dist/shared/better-auth.OT3XFeFk.mjs:45:39)...

Error: self-signed certificate in certificate chain

getting the above error. heres my code: ```js import { betterAuth } from "better-auth"; import { Pool } from "pg"; ...

failed to Failed to create user Error [PrismaClientValidationError]

Here's a condensed version under 2000 characters: --- ๐Ÿ› Better Auth SignUp Error - Password Missing Despite Existing in Schema...

Certain endpoints not working

After days of struggling I finally got a copy of BetterAuth to work with a fresh copy of Elysia and Prisma. Then I moved on to port an old project from Lucia to BetterAuth, signing in and signing up is working, same goes for creating a new organization, but listing organizations as well as any of the other BetterAuth endpoints shown in swagger all return a 404 not found, as in route does not exist. How can some routes work and others not....

B2b saas multi-tenant organization with turso

Hi guys, I try to make a multi-tenant b2b saas using turso and better-auth. I need a help how to design my relationships using better-auth organization plugins. Whats its the correct approach to manage this?

Managing Shared Drizzle Schemas in a Multi-Repo Next.js Setup

What's the best strategy to share Drizzle + BetterAuth schema definitions and related authentication code across four separate Next.js repositories, given that the auth code resides in one 'portal' repo and each of the three 'product' repos requires access to the user session & user fields, ideally minimizing redundant schema updates? (all are on the same domain with different subdomains)...

How do you show ban reason and expiry on a banned page?

Hey everyone, quick question! I'm using Better-Auth with Next.js, and I have a before hook that redirects banned users to a /banned page: `hooks: {...