Better Auth

BA

Better Auth

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

Join

bug-reports

help

getSessionCookie() return null is some cases

its confusing for some of us that getSessionCookie() is not behaving like we expect for the next reasons: - the function is not respecting the auth options specified in auth.ts ```javascript advanced: { cookies: {...

Hydration error in useListOrganizations hook

Describe the bug The useListOrganizations hook is causing React hydration mismatches between server and client rendering. next-forge version...

Cookie cache does not refresh

When using the cookie cache, the session_data cookie is not refreshed if I read the session data on the server. It refreshes if I client side do const session = authClient.useSession(), but not if I read it on the server with const session = await authClient.api.getSession({ headers }) Is it not supposed to?...

API signUpEmail not throwing error

Hello there, I'm new here. I love working with better-auth, is been really great so far! Here is my problem: After upgrading from v1.1.20 to latest, running:...

errorCallbackURL in client side social login is not working

```typescript await authClientApi.signIn.social( { provider: 'google', callbackURL: '/dashboard',...
Solution:
If state or code is missing on the oauth callback, you won't get redirected to errorCallbackURL. Becasue the error callback url can't be retrieved

bearer token returns null with OAuth provider

I want to use bearer token to pass it as header to get jwt token but i couldn't get bearer token with OAuth I tried both OnSuccess and OnResponse handler and also added cors with exposedHeader with set-auth-token with express useCase: Socket.io handeshake better-auth v: 1.2.2 frontend: nextjs...
No description

Error when updating session expiresAt

Hi, whenever better-auth decides to update my session's expiresAt field, it crashes. Here's the error: ``` 2992 }...

Limited access to webhook events

In the current structure the better-auth plugin only allows different events but not all of them for example customer.created event was excluded in the allowed events and i need it to update my database on users so can help me track user subscription state

404 with stripe plugin

hey all im getting a 404 when trying to get a stripe url: ```ts const { data, error } = await client.subscription.upgrade({ annual: biAnnual, plan: 'basic',...

`auth.api.forgotPassword` not throwing error

For this configuration: ```ts export const auth = betterAuth({ database: new Pool({...

TwoFactor plugins requires id column in schema?

I'm getting the following error message, when calling authClient.twoFactor.enable:
# SERVER_ERROR: [BetterAuthError: The field "id" does not exist in the "twoFactor" schema. Please update your drizzle schema or re-generate using "npx @better-auth/cli generate".] {
cause: undefined
}
# SERVER_ERROR: [BetterAuthError: The field "id" does not exist in the "twoFactor" schema. Please update your drizzle schema or re-generate using "npx @better-auth/cli generate".] {
cause: undefined
}
...
Solution:
will be updated

API Key Metadata is null?

For this configuration with v1.2.3: ``` export const auth = betterAuth({ database: drizzleAdapter(db, {...

Performance of `auth.api.hasPermission` seem to be very slow

Do I need to create indexes in my sqlite database to improve it? [solved]

Stripe | BetterAuth webhooks in Cloudflare need to be async error (FIXED)

Using BetterAuth on CloudFlare Pages (with Sveltekit in my case) brings this error when trying to use the Webhooks from Stripe (Based on the Docs):
"WEBHOOK_ERROR_SUBTLECRYPTOPROVIDER_CANNOT_BE_USED_IN_A_SYNCHRONOUS_CONTEXTUSE_AWAIT_CONSTRUCTEVENTASYNC_INSTEAD_OF_CONSTRUCTEVENT",
"message":
"Webhook Error: SubtleCryptoProvider cannot be used in a synchronous context. Use `await constructEventAsync(...)` instead of `constructEvent(...)`",
"WEBHOOK_ERROR_SUBTLECRYPTOPROVIDER_CANNOT_BE_USED_IN_A_SYNCHRONOUS_CONTEXTUSE_AWAIT_CONSTRUCTEVENTASYNC_INSTEAD_OF_CONSTRUCTEVENT",
"message":
"Webhook Error: SubtleCryptoProvider cannot be used in a synchronous context. Use `await constructEventAsync(...)` instead of `constructEvent(...)`",
The question is, if every environment supports Async or if you now need to decide if it should be async or sync based on the environment....
Solution:
Fixed by newest update 1.2.4

Disabling the default team requires you to provide a function for a default team

I want to disable the default team created from the org plugin entirely, but I'm required to give a function still
No description

Seems like stripe schema isn't working.

Having to manually set it in database: drizzleAdapter.

Admin plugin

after upgrade to latest Admin plugin not works, any one same problem or my config?

New update makes my plugin error

the 1.2 update made my plugin throw
Type never has no call signatures.
Type never has no call signatures.
on the client side, everything works as expect, but the error is there....

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...