Better Auth

BA

Better Auth

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

Join

bug-reports

help

Stripe | Make success_url optional?

Hey, when using embedded as ui_mode using the basic subscription implementation you get this error: "success_url is not supported with ui_mode: embedded." So my question is, if we could make success_url optional (and maybe more not sure if the cancelUrl needs also to be optional), so we can use it together in a embedded mode. Not sure if this is a feature_request or bug, but i think a nice to have for everyone not wanting to use the default stripe hosted pages....

Stripe Plugin bug

authClient.subscription.upgrade() does not work with prisma, it says a column is missing even though the prisma studio shows it exists, the neon dashboard says it exists, and I can access the field using the prisma adapter in my code no problem. `` # SERVER_ERROR: [Error [PrismaClientValidationError]: Invalid db[getModelName(model)].create()` invocation in...
Solution:
Probably because you made stripeSubscriptionId required in your schema. Just go to your schema.prisma and remove the ? on stripeSubscriptionId: String? It has to be optional because this val comes from stripe, and is put in the db down the line by the webhook handler built into better-auth...

Stripe Plugin | Received unknown parameters: params, options

As the Title states using for example: ``` getCheckoutSessionParams: async ({ user, session, plan, subscription }, request) => { return { params: { allow_promotion_codes: true, tax_id_collection: {...
Solution:
update to 1.2.2

Admin Plugin Issue with better-auth 1.2.1

found a type compatibility issue between the admin plugin and better-auth 1.2.1. the admin plugin's init function expects the old authcontext interface, but 1.2.1 requires a runMigrations property that's missing in the plugin. this causes typescript errors when trying to use the admin plugin with the updated library

Stripe Plugin | Bugs To Fix

"@better-auth/stripe": "^1.2.1",
"better-auth": "^1.2.1",
"@better-auth/stripe": "^1.2.1",
"better-auth": "^1.2.1",
...
No description

mapProfileToUser doesn't work when using ID token authentication

Hi, great work on Better Auth! When using ID tokens to log in into a sign in provider (e.g. Google with ID token and access token, as aspecified here ), mapProfileToUser parameters are not passed to the user object, thus not being stored in the database neither. I've set up additionalAttributes on the user object. If those are required, Prisma complains about those parameters not being specified while creating the user object. If those are not required they are just left as null Backend auth.ts...

Social Login state mismatch error

I migrated to v 1.2 and this broke the apple and google logins for my site. I couldn't figure out what exactly was wrong as the oauth flow wasn't completing successfully. I got this logs in my server `this is the server error logs 2025-03-03T06:39:36: ^[[2m2025-03-03T06:39:36.790Z^[[0m ^[[31mERROR^[[0m ^[[1m[Better Auth]:^[[0m State Mismatch. Verification not found { stat> 2025-03-03T06:39:36: # SERVER_ERROR: TypeError: Cannot read properties of undefined (reading 'get') 2025-03-03T06:39:36: at <unknown> (.next/server/chunks/903.js:299:18339) 2025-03-03T06:39:36: at Object.r [as handler] (.next/server/chunks/903.js:84:105326) 2025-03-03T06:39:36: at async y (.next/server/chunks/903.js:84:93446)...
Solution:
This has been solved in 1 2.3

twoFactor.verifyTotp missing trustDevice: true

I’m a little bit confused about trustDevice: true. It works with: twoFactor.verifyOtp ...

Auto Cleanup for expired verification data - fails on D1 (also sqlite?)

Using better-auth on Cloudflare D1. Since updating to better-auth 1.2, authentication fails with errors as follows: ``` (log) Query: delete from "auth_verifications" where "auth_verifications"."expiresAt" = ? -- params: ["2025-03-02T14:23:00.936Z"] (error) # SERVER_ERROR: Error: D1_TYPE_ERROR: Type 'object' not supported for value 'Sun Mar 02 2025 14:23:00 GMT+0000 (Coordinated Universal Time)'...

Fixed menu header links not visible on mobile

It is a small styling issue but when scrolling to the bottom and opening the menu, the links are not displayed. You need to open the menu at the top of the page and then the links remain fixed and are visible.

Stripe Plugin | Webhook Event Failure

Upon testing extensively, it appears the cancellation functionality of the plugin doesn't work at all. ``` 2025-03-02 01:54:13 <-- [200] POST http://localhost:3000/api/auth/stripe/webhook [evt_1Qy1jMFPuZ6ftAZV4fTCVBhl] 2025-03-02 01:54:13 --> customer.subscription.deleted [evt_1Qy1jMFPuZ6ftAZVi3u38WYV]...
No description

V1.2.0: ERR_PACKAGE_PATH_NOT_EXPORTED

``` node:internal/modules/run_main:122 triggerUncaughtException( ^ Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './node' is not defined by "exports" in /Users/user/Workspace/app/node_modules/better-auth/node_modules/better-call/package.json imported from /Users/user/Workspace/app/node_modules/better-auth/dist/integrations/node.mjs...

Secure cookie prefix

Shouldnt the logic to determine the __Secure- prefix be the same for all 3 cookie methods in https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/cookies/index.ts ? If I understand it correctly, only the createCookie function takes into account the advanced?.useSecureCookies and baseURL.startsWith("https://") part. I'm debugging a problem where "everything" worked until I added the next middlewara that uses getSessionCookie. This returns null for me. I'm using https locally but also tried to set advanced.useSecureCookies=true. So my cookies have the Secure prefix as expeced....

"/api/auth/*" rule fails on express ^5.0.0

Express changed their handling of wildcards in 5.0.0. This results in the * to do something else than intended by better auth. Maybe you could add a note in the docs or add the correct way of handling new express versions

Better-auth cannot be set up using pg Pool and postgres

It seems somewhere in the code there's hardcoded user relation when trying to set up: database: new Pool({ connectionString: process.env.DATABASE_URL, }), tables: {...

Getting a 404 on useSession and unable to use Svelte Store

Hi there, When making a request to: api/auth/use-session I am recieving a 404. This is made to a Honojs backend. Then on the Svelte side when I try use the store or value from the useSession method it is saying it is not a store. ...
No description

getSession returning null in dev mode

I am suddenly unable to login to my app when running it in dev mode as getSession returns null. This issue does not occur in production. And it is a new behavior, although I can't pinpoint what is leading to it. Below is my network calls. //network calls //headers...
Solution:
This wasn't a bug but rather my use of secure cookies and cross-domain cookies in both development & production environments. I have disabled these in dev mode and now able to sign-in.

[TypeError] Invalid URL

I have this client code: ``` import { createAuthClient } from "better-auth/react"; export const { signIn, signUp, useSession, sendVerificationEmail } = createAuthClient();...
Solution:
You also already asked for help and I gave you a solution here did you see it @samadadi ?

Typescript error on plugin schema reference field

When creating plugin for table schema, and adding reference to another table (e.g. user) I get TS error that instaed of reference it should be references ``` Object literal may only specify known properties, but 'reference' does not exist in type 'FieldAttribute<FieldType>'. Did you mean to write 'references'?ts(2561) auth-C42JqOR9.d.ts(1893, 17): The expected type comes from property 'userId' which is declared here on type '{ [x: string]: FieldAttribute<FieldType>; }'...