I am encountering an issue where all requests to endpoints under the /api/auth/* path result in a 404 Not Found error.This occurs even with a minimal project setup using better-auth and nestjs-better-auth. I have followed the standard setup procedures, but the authentication routes do not seem to be registered correctly within the NestJS application.
Steps to Reproduce
- Create a new NestJS project.
- Install better-auth and nestjs-better-auth.
- Import and configure the AuthModule from nestjs-better-auth in the root AppModule.
- Start the NestJS server.
- Make a request to any of the expected authentication endpoints (e.g., /api/auth/ok, /api/auth/sign-up/email).
Expected Behavior
Requests to /api/auth/* endpoints should be handled by the nestjs-better-auth module and return the appropriate responses, not a 404 error.
Actual Behavior
All requests to /api/auth/* endpoints result in a 404 Not Found error.
Reproduce Codes
src/auth.ts
import { betterAuth } from 'better-auth';
import { Pool } from 'pg';
export const auth = betterAuth({
database: new Pool({
connectionString: process.env.DATABASE_URL,
}),
emailAndPassword: {
enabled: true,
},
});
app.module.ts
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { AuthModule } from '@thallesp/nestjs-better-auth';
import { ConfigModule } from '@nestjs/config';
import { auth } from './auth';
@Module({
imports: [ConfigModule.forRoot(), AuthModule.forRoot(auth)],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
src/main.ts
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule, {
bodyParser: false,
});
await app.listen(process.env.PORT ?? 3000);
}
bootstrap();
Environment
Node.js Version: v22.18.0
Package manager: pnpm v10.15.0
nestjs-better-auth Version: 1.0.2
NestJS Versions:
@nestjs/common: 11.1.6
@nestjs/config: 4.0.2
@nestjs/core: 11.1.6
better-auth Version: 1.3.7
pg Version: 8.6.3
Operating System: macOS
I am encountering an issue where all requests to endpoints under the
/api/auth/*path result in a 404 Not Found error.This occurs even with a minimal project setup using better-auth and nestjs-better-auth. I have followed the standard setup procedures, but the authentication routes do not seem to be registered correctly within the NestJS application.Steps to Reproduce
Expected Behavior
Requests to /api/auth/* endpoints should be handled by the nestjs-better-auth module and return the appropriate responses, not a 404 error.
Actual Behavior
All requests to /api/auth/* endpoints result in a 404 Not Found error.
Reproduce Codes
src/auth.tsapp.module.tssrc/main.tsEnvironment
Node.js Version: v22.18.0
Package manager: pnpm v10.15.0
nestjs-better-auth Version: 1.0.2
NestJS Versions:
@nestjs/common: 11.1.6
@nestjs/config: 4.0.2
@nestjs/core: 11.1.6
better-auth Version: 1.3.7
pg Version: 8.6.3
Operating System: macOS