/api/auth/*: 404 Not Found with Nestjs Prisma v7 #2557

Open
opened 2026-03-13 10:02:56 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @hader-dev on GitHub (Dec 17, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Setup the nestjs better-auth with prisma based on the provided documentations:
1- setup nestjs app
2- add prisma service
3- setup and auth module using: ThallesP/nestjs-better-auth
4- hit /auth/ok

Current vs. Expected behavior

With version 1.4.7 i got:

Image

After downgrading to 1.4.5 it worked:

Image

What version of Better Auth are you using?

1.4.7

System info

{
  "system": {
    "platform": "linux",
    "arch": "x64",
    "version": "#1 SMP PREEMPT_DYNAMIC Tue Dec  9 00:25:56 UTC 2025",
    "release": "6.17.11-200.fc42.x86_64",
    "cpuCount": 16,
    "cpuModel": "AMD Ryzen 7 7700 8-Core Processor",
    "totalMemory": "31.04 GB",
    "freeMemory": "13.03 GB"
  },
  "node": {
    "version": "v22.19.0",
    "env": "development"
  },
  "packageManager": {
    "name": "npm",
    "version": "10.9.3"
  },
  "frameworks": null,
  "databases": [
    {
      "name": "pg",
      "version": "^8.16.3"
    },
    {
      "name": "@prisma/client",
      "version": "^7.1.0"
    }
  ],
  "betterAuth": {
    "version": "1.4.7",
    "config": {}
  }
}

Which area(s) are affected? (Select all that apply)

Backend

Auth config (if applicable)

// src/core/auth/auth.module.ts
import { Logger, Module } from '@nestjs/common';
import { AuthModule as BetterAuthModule } from '@thallesp/nestjs-better-auth';
import { betterAuth } from 'better-auth';
import { prismaAdapter } from 'better-auth/adapters/prisma';
import { AuthConfig } from '../../config/auth.config';
import { PrismaService } from '../prisma/prisma.service';

@Module({
  imports: [
    BetterAuthModule.forRootAsync({
      useFactory: (prismaService: PrismaService, authConfig: AuthConfig) => {
        Logger.log(
          `[AuthModule] Initializing Better Auth with URL: ${authConfig.BETTER_AUTH_URL}`,
        );

        return {
          auth: betterAuth({
            url: authConfig.BETTER_AUTH_URL,
            secret: authConfig.BETTER_AUTH_SECRET,
            database: prismaAdapter(prismaService, {
              provider: 'postgresql',
            }),
            basePath: '/auth',
            emailAndPassword: { enabled: true },
            trustedOrigins: [authConfig.BETTER_AUTH_URL],
          }),
        };
      },
      inject: [PrismaService, AuthConfig],
    }),
  ],
})
export class AuthModule {}

Additional context

No response

Originally created by @hader-dev on GitHub (Dec 17, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Setup the nestjs better-auth with prisma based on the provided documentations: 1- setup nestjs app 2- add prisma service 3- setup and auth module using: `ThallesP/nestjs-better-auth` 4- hit `/auth/ok` ### Current vs. Expected behavior With version 1.4.7 i got: <img width="1106" height="118" alt="Image" src="https://github.com/user-attachments/assets/925ab700-b242-4401-83f2-55f3ad9037d8" /> After downgrading to 1.4.5 it worked: <img width="1074" height="169" alt="Image" src="https://github.com/user-attachments/assets/049beb0f-02fc-4561-ab36-02699301ab45" /> ### What version of Better Auth are you using? 1.4.7 ### System info ```bash { "system": { "platform": "linux", "arch": "x64", "version": "#1 SMP PREEMPT_DYNAMIC Tue Dec 9 00:25:56 UTC 2025", "release": "6.17.11-200.fc42.x86_64", "cpuCount": 16, "cpuModel": "AMD Ryzen 7 7700 8-Core Processor", "totalMemory": "31.04 GB", "freeMemory": "13.03 GB" }, "node": { "version": "v22.19.0", "env": "development" }, "packageManager": { "name": "npm", "version": "10.9.3" }, "frameworks": null, "databases": [ { "name": "pg", "version": "^8.16.3" }, { "name": "@prisma/client", "version": "^7.1.0" } ], "betterAuth": { "version": "1.4.7", "config": {} } } ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript // src/core/auth/auth.module.ts import { Logger, Module } from '@nestjs/common'; import { AuthModule as BetterAuthModule } from '@thallesp/nestjs-better-auth'; import { betterAuth } from 'better-auth'; import { prismaAdapter } from 'better-auth/adapters/prisma'; import { AuthConfig } from '../../config/auth.config'; import { PrismaService } from '../prisma/prisma.service'; @Module({ imports: [ BetterAuthModule.forRootAsync({ useFactory: (prismaService: PrismaService, authConfig: AuthConfig) => { Logger.log( `[AuthModule] Initializing Better Auth with URL: ${authConfig.BETTER_AUTH_URL}`, ); return { auth: betterAuth({ url: authConfig.BETTER_AUTH_URL, secret: authConfig.BETTER_AUTH_SECRET, database: prismaAdapter(prismaService, { provider: 'postgresql', }), basePath: '/auth', emailAndPassword: { enabled: true }, trustedOrigins: [authConfig.BETTER_AUTH_URL], }), }; }, inject: [PrismaService, AuthConfig], }), ], }) export class AuthModule {} ``` ### Additional context _No response_
GiteaMirror added the bug label 2026-03-13 10:02:56 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Dec 17, 2025):

Hi @hader-dev! I'm Dosu and I’m helping the better-auth team.

This 404 issue with /auth/ok in better-auth 1.4.7 is caused by stricter basePath/baseURL handling introduced in 1.4.6+. The handler now requires that the route where you mount the handler (e.g., /auth) matches the computed basePath from your config. If there’s any mismatch, all endpoints (including /auth/ok) return 404—even if it worked in 1.4.5. This is a known regression for Express/NestJS setups and is not a Prisma-specific bug [source].

How to fix:
In your NestJS main.ts, after initializing your app, mount the better-auth handler directly on the Express instance with a regex that matches all /auth/* routes. For example:

// main.ts
const express = app.getHttpAdapter().getInstance();
express.all(/^\/auth\/.*$/, toNodeHandler(auth));

This ensures requests to /auth/ok and other endpoints are routed correctly [source].

Prisma v7 caveat:
better-auth 1.4.7 does not officially support Prisma v7. You may encounter peer dependency issues or silent runtime failures. Manual workarounds are required: move connection settings to a separate config, update generator provider, and ensure all model/field names match your Prisma schema. Skipping these can cause endpoints to silently fail or not register [source].

If you still see 404s after mounting the handler as above, enable debug logs in your Prisma adapter config and check for errors during startup.

Keep an eye on future better-auth releases for improved Prisma v7 support and more robust route handling.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Dec 17, 2025): <!-- Greeting --> Hi @hader-dev! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> This 404 issue with `/auth/ok` in better-auth 1.4.7 is caused by stricter basePath/baseURL handling introduced in 1.4.6+. The handler now requires that the route where you mount the handler (e.g., `/auth`) matches the computed basePath from your config. If there’s any mismatch, all endpoints (including `/auth/ok`) return 404—even if it worked in 1.4.5. This is a known regression for Express/NestJS setups and is not a Prisma-specific bug [[source](https://github.com/better-auth/better-auth/issues/6636)]. **How to fix:** In your NestJS `main.ts`, after initializing your app, mount the better-auth handler directly on the Express instance with a regex that matches all `/auth/*` routes. For example: ```typescript // main.ts const express = app.getHttpAdapter().getInstance(); express.all(/^\/auth\/.*$/, toNodeHandler(auth)); ``` This ensures requests to `/auth/ok` and other endpoints are routed correctly [[source](https://github.com/better-auth/better-auth/issues/6636)]. **Prisma v7 caveat:** better-auth 1.4.7 does not officially support Prisma v7. You may encounter peer dependency issues or silent runtime failures. Manual workarounds are required: move connection settings to a separate config, update generator provider, and ensure all model/field names match your Prisma schema. Skipping these can cause endpoints to silently fail or not register [[source](https://github.com/better-auth/better-auth/issues/6746)]. If you still see 404s after mounting the handler as above, enable debug logs in your Prisma adapter config and check for errors during startup. Keep an eye on future better-auth releases for improved Prisma v7 support and more robust route handling. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/e9cd5a10-1db6-43a5-bb13-153e55fe14b4?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/e9cd5a10-1db6-43a5-bb13-153e55fe14b4?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/e9cd5a10-1db6-43a5-bb13-153e55fe14b4?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/e9cd5a10-1db6-43a5-bb13-153e55fe14b4?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/e9cd5a10-1db6-43a5-bb13-153e55fe14b4?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/e9cd5a10-1db6-43a5-bb13-153e55fe14b4?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/e9cd5a10-1db6-43a5-bb13-153e55fe14b4?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20404%20issue%20with%20%60/auth/ok%60%20in%20better-auth%201.4.7%20is%20caused%20by%20stricter%20basePath/baseURL%20handling%20introduced%20in%201.4.6%2B.%20The%20handler%20now%20requires%20that%20the%20route%20where%20you%20mount%20the%20handler%20%28e.g.%2C%20%60/auth%60%29%20matches%20the%20computed%20basePath%20from%20your%20config.%20If%20there%E2%80%99s%20any%20mismatch%2C%20all%20endpoints%20%28including%20%60/auth/ok%60%29%20return%20404%E2%80%94even%20if%20it%20worked%20in%201.4.5.%20This%20is%20a%20known%20regression%20for%20Express/NestJS%20setups%20and%20is%20not%20a%20Prisma-specific%20bug%20%5B%5Bsource%5D%28https%3A//github.com/better-auth/better-auth/issues/6636%29%5D.%0A%0A%2A%2AHow%20to%20fix%3A%2A%2A%20%20%0AIn%20your%20NestJS%20%60main.ts%60%2C%20after%20initializing%20your%20app%2C%20mount%20the%20better-auth%20handler%20directly%20on%20the%20Express%20instance%20with%20a%20regex%20that%20matches%20all%20%60/auth/%2A%60%20routes.%20For%20example%3A%0A%0A%60%60%60typescript%0A//%20main.ts%0Aconst%20express%20%3D%20app.getHttpAdapter%28%29.getInstance%28%29%3B%0Aexpress.all%28/%5E%5C/auth%5C/.%2A%24/%2C%20toNodeHandler%28auth%29%29%3B%0A%60%60%60%0A%0AThis%20ensures%20requests%20to%20%60/auth/ok%60%20and%20other%20endpoints%20are%20routed%20correctly%20%5B%5Bsource%5D%28https%3A//github.com/better-auth/better-auth/issues/6636%29%5D.%0A%0A%2A%2APrisma%20v7%20caveat%3A%2A%2A%20%20%0Abetter-auth%201.4.7%20does%20not%20officially%20support%20Prisma%20v7.%20You%20may%20encounter%20peer%20dependency%20issues%20or%20silent%20runtime%20failures.%20Manual%20workarounds%20are%20required%3A%20move%20connection%20settings%20to%20a%20separate%20config%2C%20update%20generator%20provider%2C%20and%20ensure%20all%20model/field%20names%20match%20your%20Prisma%20schema.%20Skipping%20these%20can%20cause%20endpoints%20to%20silently%20fail%20or%20not%20register%20%5B%5Bsource%5D%28https%3A//github.com/better-auth/better-auth/issues/6746%29%5D.%0A%0AIf%20you%20still%20see%20404s%20after%20mounting%20the%20handler%20as%20above%2C%20enable%20debug%20logs%20in%20your%20Prisma%20adapter%20config%20and%20check%20for%20errors%20during%20startup.%0A%0AKeep%20an%20eye%20on%20future%20better-auth%20releases%20for%20improved%20Prisma%20v7%20support%20and%20more%20robust%20route%20handling.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/6828)
Author
Owner

@PEAL-26 commented on GitHub (Dec 23, 2025):

Hi @hader-dev! I'm Dosu and I’m helping the better-auth team.

This 404 issue with /auth/ok in better-auth 1.4.7 is caused by stricter basePath/baseURL handling introduced in 1.4.6+. The handler now requires that the route where you mount the handler (e.g., /auth) matches the computed basePath from your config. If there’s any mismatch, all endpoints (including /auth/ok) return 404—even if it worked in 1.4.5. This is a known regression for Express/NestJS setups and is not a Prisma-specific bug [source].

How to fix: In your NestJS main.ts, after initializing your app, mount the better-auth handler directly on the Express instance with a regex that matches all /auth/* routes. For example:

// main.ts
const express = app.getHttpAdapter().getInstance();
express.all(/^/auth/.*$/, toNodeHandler(auth));
This ensures requests to /auth/ok and other endpoints are routed correctly [source].

Prisma v7 caveat: better-auth 1.4.7 does not officially support Prisma v7. You may encounter peer dependency issues or silent runtime failures. Manual workarounds are required: move connection settings to a separate config, update generator provider, and ensure all model/field names match your Prisma schema. Skipping these can cause endpoints to silently fail or not register [source].

If you still see 404s after mounting the handler as above, enable debug logs in your Prisma adapter config and check for errors during startup.

Keep an eye on future better-auth releases for improved Prisma v7 support and more robust route handling.

To reply, just mention @dosu.

How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

I had the same problem, and it was solved with this solution.

@PEAL-26 commented on GitHub (Dec 23, 2025): > Hi [@hader-dev](https://github.com/hader-dev)! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. > > This 404 issue with `/auth/ok` in better-auth 1.4.7 is caused by stricter basePath/baseURL handling introduced in 1.4.6+. The handler now requires that the route where you mount the handler (e.g., `/auth`) matches the computed basePath from your config. If there’s any mismatch, all endpoints (including `/auth/ok`) return 404—even if it worked in 1.4.5. This is a known regression for Express/NestJS setups and is not a Prisma-specific bug [[source](https://github.com/better-auth/better-auth/issues/6636)]. > > **How to fix:** In your NestJS `main.ts`, after initializing your app, mount the better-auth handler directly on the Express instance with a regex that matches all `/auth/*` routes. For example: > > // main.ts > const express = app.getHttpAdapter().getInstance(); > express.all(/^\/auth\/.*$/, toNodeHandler(auth)); > This ensures requests to `/auth/ok` and other endpoints are routed correctly [[source](https://github.com/better-auth/better-auth/issues/6636)]. > > **Prisma v7 caveat:** better-auth 1.4.7 does not officially support Prisma v7. You may encounter peer dependency issues or silent runtime failures. Manual workarounds are required: move connection settings to a separate config, update generator provider, and ensure all model/field names match your Prisma schema. Skipping these can cause endpoints to silently fail or not register [[source](https://github.com/better-auth/better-auth/issues/6746)]. > > If you still see 404s after mounting the handler as above, enable debug logs in your Prisma adapter config and check for errors during startup. > > Keep an eye on future better-auth releases for improved Prisma v7 support and more robust route handling. > > _To reply, just mention [@dosu](https://go.dosu.dev/dosubot)._ > > How did I do? [Good](https://app.dosu.dev/response-feedback/e9cd5a10-1db6-43a5-bb13-153e55fe14b4?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/e9cd5a10-1db6-43a5-bb13-153e55fe14b4?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/e9cd5a10-1db6-43a5-bb13-153e55fe14b4?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/e9cd5a10-1db6-43a5-bb13-153e55fe14b4?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/e9cd5a10-1db6-43a5-bb13-153e55fe14b4?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/e9cd5a10-1db6-43a5-bb13-153e55fe14b4?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/e9cd5a10-1db6-43a5-bb13-153e55fe14b4?feedback_type=other) > > [![Chat with Dosu](https://camo.githubusercontent.com/7c571478962a6b8a5d47cac74b6824c75e4f6731bba52377e6007f9150462923/68747470733a2f2f646f73752e6465762f646f73752d636861742d62616467652e737667)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github) [![Open in Cursor](https://camo.githubusercontent.com/bdf7dbded65ee585887f47e5fd6fa099ea0933088b4b03d02e83b4def50154d4/68747470733a2f2f646f73752e6465762f646f73752d696e2d637572736f722e737667)](https://cursor.com/link/prompt?text=This%20404%20issue%20with%20%60/auth/ok%60%20in%20better-auth%201.4.7%20is%20caused%20by%20stricter%20basePath/baseURL%20handling%20introduced%20in%201.4.6%2B.%20The%20handler%20now%20requires%20that%20the%20route%20where%20you%20mount%20the%20handler%20%28e.g.%2C%20%60/auth%60%29%20matches%20the%20computed%20basePath%20from%20your%20config.%20If%20there%E2%80%99s%20any%20mismatch%2C%20all%20endpoints%20%28including%20%60/auth/ok%60%29%20return%20404%E2%80%94even%20if%20it%20worked%20in%201.4.5.%20This%20is%20a%20known%20regression%20for%20Express/NestJS%20setups%20and%20is%20not%20a%20Prisma-specific%20bug%20%5B%5Bsource%5D%28https%3A//github.com/better-auth/better-auth/issues/6636%29%5D.%0A%0A%2A%2AHow%20to%20fix%3A%2A%2A%20%20%0AIn%20your%20NestJS%20%60main.ts%60%2C%20after%20initializing%20your%20app%2C%20mount%20the%20better-auth%20handler%20directly%20on%20the%20Express%20instance%20with%20a%20regex%20that%20matches%20all%20%60/auth/%2A%60%20routes.%20For%20example%3A%0A%0A%60%60%60typescript%0A//%20main.ts%0Aconst%20express%20%3D%20app.getHttpAdapter%28%29.getInstance%28%29%3B%0Aexpress.all%28/%5E%5C/auth%5C/.%2A%24/%2C%20toNodeHandler%28auth%29%29%3B%0A%60%60%60%0A%0AThis%20ensures%20requests%20to%20%60/auth/ok%60%20and%20other%20endpoints%20are%20routed%20correctly%20%5B%5Bsource%5D%28https%3A//github.com/better-auth/better-auth/issues/6636%29%5D.%0A%0A%2A%2APrisma%20v7%20caveat%3A%2A%2A%20%20%0Abetter-auth%201.4.7%20does%20not%20officially%20support%20Prisma%20v7.%20You%20may%20encounter%20peer%20dependency%20issues%20or%20silent%20runtime%20failures.%20Manual%20workarounds%20are%20required%3A%20move%20connection%20settings%20to%20a%20separate%20config%2C%20update%20generator%20provider%2C%20and%20ensure%20all%20model/field%20names%20match%20your%20Prisma%20schema.%20Skipping%20these%20can%20cause%20endpoints%20to%20silently%20fail%20or%20not%20register%20%5B%5Bsource%5D%28https%3A//github.com/better-auth/better-auth/issues/6746%29%5D.%0A%0AIf%20you%20still%20see%20404s%20after%20mounting%20the%20handler%20as%20above%2C%20enable%20debug%20logs%20in%20your%20Prisma%20adapter%20config%20and%20check%20for%20errors%20during%20startup.%0A%0AKeep%20an%20eye%20on%20future%20better-auth%20releases%20for%20improved%20Prisma%20v7%20support%20and%20more%20robust%20route%20handling.) [![Join Discord](https://camo.githubusercontent.com/7d2066700925db1e370d956834f9ea0e5bc92cecbe84963fbd2a363e45091b4e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6a6f696e2d3538363546323f6c6f676f3d646973636f7264266c6f676f436f6c6f723d7768697465266c6162656c3d)](https://go.dosu.dev/discord-bot) [![Share on X](https://camo.githubusercontent.com/a8bd7f3fcf3f5e3bd124eee9ae50ae2ac17b40971726665ac2121d48f9aee155/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f582d73686172652d626c61636b)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/6828) I had the same problem, and it was solved with this solution.
Author
Owner

@maxdevos49 commented on GitHub (Dec 31, 2025):

Made a PR for this issue in better-call: https://github.com/better-auth/better-call/pull/93

Issue seems to be the request url is constructed incorrectly for middleware wildcard endpoints and some subrouter endpoints resulting in a trailing forward slash. Works great for me with pnpm patch

@maxdevos49 commented on GitHub (Dec 31, 2025): Made a PR for this issue in better-call: https://github.com/better-auth/better-call/pull/93 Issue seems to be the request url is constructed incorrectly for middleware wildcard endpoints and some subrouter endpoints resulting in a trailing forward slash. Works great for me with pnpm patch
Author
Owner

@BayBreezy commented on GitHub (Jan 4, 2026):

Only fix for now is downgrading to v1.4.5 in NestJS

@BayBreezy commented on GitHub (Jan 4, 2026): Only fix for now is downgrading to v1.4.5 in NestJS
Author
Owner

@ussfranck commented on GitHub (Jan 18, 2026):

Hey man 👋
I just went through this exact nightmare and I finally have a working, clean solution with:

  • NestJS latest
  • BetterAuth (latest)
  • Prisma v7 (latest)
  • Factory-based integration (no hack, no inline config, no magic)

The root problems are:

  • Prisma v7 now requires an adapter or accelerateUrl
  • BetterAuth + NestJS must be wired via a factory
  • You cannot instantiate Prisma the old way anymore
  • You must let NestJS own the PrismaService and inject it

I’ve created a full working template here:

👉 https://github.com/ussfranck/nestjs-better-auth-prisma

What this repo shows:

  • Proper PrismaService with adapter
  • Proper createAuth(prismaService) factory
  • Proper NestJS module wiring with useFactory
  • BetterAuth fully working: register, login, session, logout
  • Prisma v7 compatible
  • No hacks, no copying generated files, no CLI weirdness
  • Embedded common decorator like @Session() @AllowAnonymous() @OptionalAuth() etc.

If you’re stuck with:

PrismaClient needs to be constructed with adapter
or
Nest can't resolve dependencies
or
BetterAuth + Prisma v7 + NestJS not working

→ This repo solves all of it.

I lost a full day on this, so I hope this saves you some hours .

@ussfranck commented on GitHub (Jan 18, 2026): Hey man 👋 I just went through this exact nightmare and I finally have a **working, clean solution** with: - NestJS latest - BetterAuth (latest) - Prisma v7 (latest) - Factory-based integration (no hack, no inline config, no magic) The root problems are: - Prisma v7 now **requires an adapter or accelerateUrl** - BetterAuth + NestJS **must be wired via a factory** - You **cannot** instantiate Prisma the old way anymore - You must let NestJS own the PrismaService and inject it I’ve created a **full working template** here: 👉 https://github.com/ussfranck/nestjs-better-auth-prisma What this repo shows: - ✅ Proper PrismaService with adapter - ✅ Proper `createAuth(prismaService)` factory - ✅ Proper NestJS module wiring with `useFactory` - ✅ BetterAuth fully working: register, login, session, logout - ✅ Prisma v7 compatible - ✅ No hacks, no copying generated files, no CLI weirdness - ✅ Embedded common decorator like @Session() @AllowAnonymous() @OptionalAuth() etc. If you’re stuck with: > PrismaClient needs to be constructed with adapter > or > Nest can't resolve dependencies > or > BetterAuth + Prisma v7 + NestJS not working → This repo solves all of it. I lost a full day on this, so I hope this saves you some hours .
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#2557