BetterAuth mounted but routes returning 404 in NestJS

Hello, I’m integrating @thallesp/nestjs-better-auth into a NestJS project and it seems to initialize fine and the console shows:
[2025-10-26 17:14:22.786 +0100] INFO (26116): AuthModule initialized BetterAuth on '/auth/*' {"context":"AuthModule"}
[2025-10-26 17:14:22.786 +0100] INFO (26116): AuthModule initialized BetterAuth on '/auth/*' {"context":"AuthModule"}
however when I try to do anything (register, login, oath...) it always returns 404 error
POST http://localhost:5000/auth/sign-up/email

{
"message": "Cannot POST /auth/sign-in/email/",
"error": "Not Found",
"statusCode": 404
}
POST http://localhost:5000/auth/sign-up/email

{
"message": "Cannot POST /auth/sign-in/email/",
"error": "Not Found",
"statusCode": 404
}
this is my AuthModule:
@Module({
imports: [
DatabaseModule,
BetterAuthModule.forRootAsync({
imports: [DatabaseModule, ConfigModule],
useFactory: (database: NodePgDatabase, configService: ConfigService) => ({
auth: betterAuth({
emailAndPassword: {
enabled: true,
},

basePath: "/auth",

trustedOrigins:
configService
.get<string>("ALLOWED_ORIGINS")
?.split(",")
?.map((origin) => origin.trim())
?.filter((origin) => origin.length > 0) || [],

database: drizzleAdapter(database, { provider: "pg" }),

socialProviders: {
github: {
clientId: configService.getOrThrow("GITHUB_CLIENT_ID"),
clientSecret: configService.getOrThrow("GITHUB_CLIENT_SECRET"),
},
google: {
clientId: configService.getOrThrow("GOOGLE_CLIENT_ID"),
clientSecret: configService.getOrThrow("GOOGLE_CLIENT_SECRET"),
},
},
}),
}),
inject: [DATABASE_CONNECTION, ConfigService],
}),
],
exports: [BetterAuthModule],
})
export class AuthModule {}
@Module({
imports: [
DatabaseModule,
BetterAuthModule.forRootAsync({
imports: [DatabaseModule, ConfigModule],
useFactory: (database: NodePgDatabase, configService: ConfigService) => ({
auth: betterAuth({
emailAndPassword: {
enabled: true,
},

basePath: "/auth",

trustedOrigins:
configService
.get<string>("ALLOWED_ORIGINS")
?.split(",")
?.map((origin) => origin.trim())
?.filter((origin) => origin.length > 0) || [],

database: drizzleAdapter(database, { provider: "pg" }),

socialProviders: {
github: {
clientId: configService.getOrThrow("GITHUB_CLIENT_ID"),
clientSecret: configService.getOrThrow("GITHUB_CLIENT_SECRET"),
},
google: {
clientId: configService.getOrThrow("GOOGLE_CLIENT_ID"),
clientSecret: configService.getOrThrow("GOOGLE_CLIENT_SECRET"),
},
},
}),
}),
inject: [DATABASE_CONNECTION, ConfigService],
}),
],
exports: [BetterAuthModule],
})
export class AuthModule {}
Solution:
updating the packages related to @nestjs to the latest version solves the issue
Jump to solution
2 Replies
Solution
attano
attano1h ago
updating the packages related to @nestjs to the latest version solves the issue

Did you find this page helpful?