Devium
Devium
BABetter Auth
Created by Devium on 3/27/2025 in #help
Google Oauth Scopes Error
thank you!
6 replies
BABetter Auth
Created by Devium on 3/27/2025 in #help
Google Oauth Scopes Error
@bekacru do you know what the issue could be?
6 replies
BABetter Auth
Created by Devium on 2/12/2025 in #help
TypeError on Signup
and i love what your doing with the library
16 replies
BABetter Auth
Created by Devium on 2/12/2025 in #help
TypeError on Signup
Than you for the advice, ill try it out :)
16 replies
BABetter Auth
Created by Devium on 2/12/2025 in #help
TypeError on Signup
Ok thank you!
16 replies
BABetter Auth
Created by Devium on 2/12/2025 in #help
TypeError on Signup
No worries, it still seems to output this without a full stack
✓ Compiled /api/auth/[...all] in 438ms (1106 modules)
2025-02-12T02:38:16.277Z ERROR [Better Auth]: TypeError [TypeError: The "payload" argument must be of type object. Received null] {
code: 'ERR_INVALID_ARG_TYPE'
}
POST /api/auth/sign-up/email 500 in 1471ms
✓ Compiled /api/auth/[...all] in 438ms (1106 modules)
2025-02-12T02:38:16.277Z ERROR [Better Auth]: TypeError [TypeError: The "payload" argument must be of type object. Received null] {
code: 'ERR_INVALID_ARG_TYPE'
}
POST /api/auth/sign-up/email 500 in 1471ms
16 replies
BABetter Auth
Created by Devium on 2/12/2025 in #help
TypeError on Signup
@begot
16 replies
BABetter Auth
Created by Devium on 2/12/2025 in #help
TypeError on Signup
Like this?
// src/lib/auth.ts
import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { PrismaClient } from "@prisma/client";
import { createAuthMiddleware, APIError } from "better-auth/api";

const prisma = new PrismaClient();

export const auth = betterAuth({
emailAndPassword: {
enabled: true,
},
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
},
},
database: prismaAdapter(prisma, {
provider: "postgresql", // or "mysql", "postgresql", etc.
}),
hooks: {
error: createAuthMiddleware(async (ctx) => {
if (ctx.error instanceof Error) {
console.error("Error hook stack:", ctx.error.stack);
}
// Rethrow the error so that the endpoint responds with the proper error.
throw ctx.error;
}),
},
});
// src/lib/auth.ts
import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { PrismaClient } from "@prisma/client";
import { createAuthMiddleware, APIError } from "better-auth/api";

const prisma = new PrismaClient();

export const auth = betterAuth({
emailAndPassword: {
enabled: true,
},
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
},
},
database: prismaAdapter(prisma, {
provider: "postgresql", // or "mysql", "postgresql", etc.
}),
hooks: {
error: createAuthMiddleware(async (ctx) => {
if (ctx.error instanceof Error) {
console.error("Error hook stack:", ctx.error.stack);
}
// Rethrow the error so that the endpoint responds with the proper error.
throw ctx.error;
}),
},
});
16 replies
BABetter Auth
Created by Devium on 2/12/2025 in #help
TypeError on Signup
would i need to extend a function to log the error in the [all] api route?
16 replies
BABetter Auth
Created by Devium on 2/12/2025 in #help
TypeError on Signup
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model User {
id Int @id @default(autoincrement())
email String @unique
name String?
emailVerified Boolean
image String?
createdAt DateTime
updatedAt DateTime
sessions Session[]
accounts Account[]
profile Profile? // new one-to-one relation with Profile

@@map("user")
}

model Session {
id String @id
expiresAt DateTime
token String
createdAt DateTime
updatedAt DateTime
ipAddress String?
userAgent String?

userId Int
user User @relation(fields: [userId], references: [id], onDelete: Cascade)

@@unique([token])
@@map("session")
}

model Account {
id String @id
accountId String
providerId String

userId Int
user User @relation(fields: [userId], references: [id], onDelete: Cascade)

accessToken String?
refreshToken String?
idToken String?
accessTokenExpiresAt DateTime?
refreshTokenExpiresAt DateTime?
scope String?
password String?
createdAt DateTime
updatedAt DateTime

@@map("account")
}

model Verification {
id String @id
identifier String
value String
expiresAt DateTime
createdAt DateTime?
updatedAt DateTime?

@@map("verification")
}

model Profile {
id Int @id @default(autoincrement())
userId Int @unique
firstName String?
lastName String?
dateOfBirth DateTime?
address String?
gender String? // will store "Male", "Female" or "Other"
emailPersonal String?
emailWork String?

user User @relation(fields: [userId], references: [id], onDelete: Cascade)

@@map("profile")
}
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model User {
id Int @id @default(autoincrement())
email String @unique
name String?
emailVerified Boolean
image String?
createdAt DateTime
updatedAt DateTime
sessions Session[]
accounts Account[]
profile Profile? // new one-to-one relation with Profile

@@map("user")
}

model Session {
id String @id
expiresAt DateTime
token String
createdAt DateTime
updatedAt DateTime
ipAddress String?
userAgent String?

userId Int
user User @relation(fields: [userId], references: [id], onDelete: Cascade)

@@unique([token])
@@map("session")
}

model Account {
id String @id
accountId String
providerId String

userId Int
user User @relation(fields: [userId], references: [id], onDelete: Cascade)

accessToken String?
refreshToken String?
idToken String?
accessTokenExpiresAt DateTime?
refreshTokenExpiresAt DateTime?
scope String?
password String?
createdAt DateTime
updatedAt DateTime

@@map("account")
}

model Verification {
id String @id
identifier String
value String
expiresAt DateTime
createdAt DateTime?
updatedAt DateTime?

@@map("verification")
}

model Profile {
id Int @id @default(autoincrement())
userId Int @unique
firstName String?
lastName String?
dateOfBirth DateTime?
address String?
gender String? // will store "Male", "Female" or "Other"
emailPersonal String?
emailWork String?

user User @relation(fields: [userId], references: [id], onDelete: Cascade)

@@map("profile")
}
16 replies