[GH-ISSUE #7153] The Figma provider returns a 404 not found error after access authorization. #28071

Closed
opened 2026-04-17 19:27:10 -05:00 by GiteaMirror · 29 comments
Owner

Originally created by @Muhammed21 on GitHub (Jan 6, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/7153

Originally assigned to: @bytaesu on GitHub.

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

I’m using Better Auth in a project with:

  • Backend: NestJS (Express)
  • Frontend: Next.js

I configured the Figma OAuth provider using socialProviders.

For architectural reasons, I do not expose Better Auth’s HTTP routes directly to the frontend.
Instead:

I expose custom NestJS API routes

These routes call auth.api.* methods internally

The Next.js frontend only talks to my NestJS backend


Authentication flow

  1. Next.js frontend calls: POST /api/v1/auth/sign-in
  2. This route calls:
@Post('sign-in')
@UsePipes(new ZodValidationPipe(signInSchema))
async signIn(
  @Body() body: SignInQueryHttpDTO,
  @Req() req: Request,
  @Res() res: Response, // with Express
): Promise<void> {
  const domainQuery = SignInQuery.create(body.provider, req.headers);
  const result = await this.repository.signIn(domainQuery);

  res.status(result.status);

  result.headers.forEach((value, key) => {
    res.setHeader(key, value);
  });

  const buffer = Buffer.from(await result.arrayBuffer());
  res.send(buffer);
}
  1. User is correctly redirected to Figma OAuth
  2. User authorizes access
  3. Figma redirects back to: /api/auth/callback/figma?code=XXX&state=YYY

👉 Up to this point, everything works correctly (state cookie, redirect, etc.).


Issue

When the OAuth callback is hit:

  • The user is redirected to: /api/auth/error?error=invalid_code
  • Server logs show: ERROR [Better Auth]: { status: 404, statusText: 'Not Found' }

Current vs. Expected behavior

Image Image Image

What version of Better Auth are you using?

^1.4.9

System info

{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 25.2.0: Tue Nov 18 21:08:48 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T8132",
    "release": "25.2.0",
    "cpuCount": 10,
    "cpuModel": "Apple M4",
    "totalMemory": "16.00 GB",
    "freeMemory": "0.26 GB"
  },
  "node": {
    "version": "v22.19.0",
    "env": "development"
  },
  "packageManager": {
    "name": "npm",
    "version": "10.9.3"
  },
  "frameworks": null,
  "databases": null,
  "betterAuth": {
    "version": "Unknown",
    "config": null
  }
}

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

Backend

Auth config (if applicable)

import { betterAuth } from 'better-auth';
import { prismaAdapter } from 'better-auth/adapters/prisma';
import { PrismaService } from '../../../../prisma/prisma.service';
import { openAPI } from 'better-auth/plugins';

export const createAuth = (prisma: PrismaService) =>
  betterAuth({
    /**
     * Better Auth configuration
     */
    baseURL: process.env.BETTER_AUTH_URL,
    secret: process.env.BETTER_AUTH_SECRET,
    basePath: '/api/auth',
    /**
     * Database configuration
     */
    database: prismaAdapter(prisma, {
      provider: 'postgresql',
    }),
    /**
     * Social providers configuration
     */
    socialProviders: {
      figma: {
        clientId: process.env.FIGMA_CLIENT_ID || '',
        clientSecret: process.env.FIGMA_CLIENT_SECRET || '',
        redirectURI: process.env.FIGMA_REDIRECT_URI || '/',
        disableDefaultScope: true,
      },
    },
    plugins: [openAPI()],
    /**
     * Session configuration
     */
    session: {
      cookieCache: {
        enabled: true,
        maxAge: 3 * 30 * 24 * 60 * 60, // 3 mois
        refreshCache: true,
      },
      expiresIn: 60 * 60 * 24 * 30, // 30 jours
      updateAge: 60 * 60 * 24, // 1 jour
      cookieOptions: {
        sameSite: process.env.NODE_ENV === 'production' ? 'lax' : 'lax',
        httpOnly: true,
        secure: process.env.NODE_ENV === 'production',
        path: '/',
      },
    },
    /**
     * Advanced configuration
     */
    advanced: {
      cookiePrefix: 'better-auth',
      useSecureCookies: process.env.NODE_ENV === 'production',
      crossSubDomainCookies: { enabled: false },
    },
    /**
     * Rate limiting configuration
     */
    rateLimit: {
      window: 15 * 60 * 1000, // 15 minutes
      max: 100,
    },
    /**
     * Trusted origins for CORS
     */
    trustedOrigins: [process.env.CLIENT_URL || 'http://localhost:3000'],
  });

export type Auth = ReturnType<typeof createAuth>;

Additional context

No response

Originally created by @Muhammed21 on GitHub (Jan 6, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/7153 Originally assigned to: @bytaesu on GitHub. ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce I’m using Better Auth in a project with: - **Backend**: NestJS (Express) - **Frontend**: Next.js I configured the **Figma** OAuth provider using `socialProviders`. For architectural reasons, I do not expose Better Auth’s HTTP routes directly to the frontend. Instead: I expose **custom NestJS API routes** These routes call `auth.api.* `methods internally The Next.js frontend only talks to my NestJS backend --- ### Authentication flow 1. Next.js frontend calls: `POST /api/v1/auth/sign-in` 2. This route calls: ```ts @Post('sign-in') @UsePipes(new ZodValidationPipe(signInSchema)) async signIn( @Body() body: SignInQueryHttpDTO, @Req() req: Request, @Res() res: Response, // with Express ): Promise<void> { const domainQuery = SignInQuery.create(body.provider, req.headers); const result = await this.repository.signIn(domainQuery); res.status(result.status); result.headers.forEach((value, key) => { res.setHeader(key, value); }); const buffer = Buffer.from(await result.arrayBuffer()); res.send(buffer); } ``` 3. User is correctly redirected to Figma OAuth 4. User authorizes access 5. Figma redirects back to: `/api/auth/callback/figma?code=XXX&state=YYY` 👉 Up to this point, everything works correctly (state cookie, redirect, etc.). --- ### Issue When the OAuth callback is hit: - The user is redirected to: `/api/auth/error?error=invalid_code` - Server logs show: `ERROR [Better Auth]: { status: 404, statusText: 'Not Found' }` ### Current vs. Expected behavior <img width="1476" height="895" alt="Image" src="https://github.com/user-attachments/assets/73d4a00e-e4e8-45a8-a2e0-9435378925cc" /> <img width="1606" height="985" alt="Image" src="https://github.com/user-attachments/assets/e5497c92-2573-42f7-8518-641863c3a171" /> <img width="1606" height="985" alt="Image" src="https://github.com/user-attachments/assets/f7840e9a-331b-478f-b6fb-83f1ed8d021b" /> ### What version of Better Auth are you using? ^1.4.9 ### System info ```bash { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 25.2.0: Tue Nov 18 21:08:48 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T8132", "release": "25.2.0", "cpuCount": 10, "cpuModel": "Apple M4", "totalMemory": "16.00 GB", "freeMemory": "0.26 GB" }, "node": { "version": "v22.19.0", "env": "development" }, "packageManager": { "name": "npm", "version": "10.9.3" }, "frameworks": null, "databases": null, "betterAuth": { "version": "Unknown", "config": null } } ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript import { betterAuth } from 'better-auth'; import { prismaAdapter } from 'better-auth/adapters/prisma'; import { PrismaService } from '../../../../prisma/prisma.service'; import { openAPI } from 'better-auth/plugins'; export const createAuth = (prisma: PrismaService) => betterAuth({ /** * Better Auth configuration */ baseURL: process.env.BETTER_AUTH_URL, secret: process.env.BETTER_AUTH_SECRET, basePath: '/api/auth', /** * Database configuration */ database: prismaAdapter(prisma, { provider: 'postgresql', }), /** * Social providers configuration */ socialProviders: { figma: { clientId: process.env.FIGMA_CLIENT_ID || '', clientSecret: process.env.FIGMA_CLIENT_SECRET || '', redirectURI: process.env.FIGMA_REDIRECT_URI || '/', disableDefaultScope: true, }, }, plugins: [openAPI()], /** * Session configuration */ session: { cookieCache: { enabled: true, maxAge: 3 * 30 * 24 * 60 * 60, // 3 mois refreshCache: true, }, expiresIn: 60 * 60 * 24 * 30, // 30 jours updateAge: 60 * 60 * 24, // 1 jour cookieOptions: { sameSite: process.env.NODE_ENV === 'production' ? 'lax' : 'lax', httpOnly: true, secure: process.env.NODE_ENV === 'production', path: '/', }, }, /** * Advanced configuration */ advanced: { cookiePrefix: 'better-auth', useSecureCookies: process.env.NODE_ENV === 'production', crossSubDomainCookies: { enabled: false }, }, /** * Rate limiting configuration */ rateLimit: { window: 15 * 60 * 1000, // 15 minutes max: 100, }, /** * Trusted origins for CORS */ trustedOrigins: [process.env.CLIENT_URL || 'http://localhost:3000'], }); export type Auth = ReturnType<typeof createAuth>; ``` ### Additional context _No response_
GiteaMirror added the locked label 2026-04-17 19:27:10 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Jan 6, 2026):

It seems like you're encountering a 404 error after the Figma OAuth authorization in your Better Auth configuration. Based on the troubleshooting context, here are a few potential steps to investigate:

  1. Check Redirect URI: Ensure that the redirect URI you provided in your Figma application settings matches the redirectURI configured in your Better Auth settings. A mismatch here can lead to 404 errors.

  2. API Path Configuration: In your betterAuth configuration, the basePath is set to /api/auth. Verify that the callback URL Figma is redirecting to aligns with your NestJS API routes setup. Since the callback hits /api/auth/callback/figma, ensure that your NestJS routes are properly set up to handle this endpoint.

  3. Descriptive Error Handling: Enhance logging in your API routes to capture more details about failed requests. This can help identify whether the request is reaching your backend or failing at an earlier stage.

  4. Inspecting Client and Server Logs: Monitor both the client-side and server-side logs for any additional error messages or details that could provide insights into the request flow.

Additionally, note that there are recent discussions on similar issues related to the Figma provider, like 404 errors in the context of NextJS and Express [1], [2]. Exploring these might give you further insights.

Please feel free to share any additional details or ask more questions if you need help investigating this further!

If you need more help, tag @better-auth-agent in a comment so I can respond.

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3716005993 --> @better-auth-agent[bot] commented on GitHub (Jan 6, 2026): It seems like you're encountering a 404 error after the Figma OAuth authorization in your Better Auth configuration. Based on the troubleshooting context, here are a few potential steps to investigate: 1. **Check Redirect URI**: Ensure that the redirect URI you provided in your Figma application settings matches the `redirectURI` configured in your Better Auth settings. A mismatch here can lead to 404 errors. 2. **API Path Configuration**: In your `betterAuth` configuration, the `basePath` is set to `/api/auth`. Verify that the callback URL Figma is redirecting to aligns with your NestJS API routes setup. Since the callback hits `/api/auth/callback/figma`, ensure that your NestJS routes are properly set up to handle this endpoint. 3. **Descriptive Error Handling**: Enhance logging in your API routes to capture more details about failed requests. This can help identify whether the request is reaching your backend or failing at an earlier stage. 4. **Inspecting Client and Server Logs**: Monitor both the client-side and server-side logs for any additional error messages or details that could provide insights into the request flow. Additionally, note that there are recent discussions on similar issues related to the Figma provider, like 404 errors in the context of NextJS and Express [[1]](https://github.com/better-auth/better-auth/issues/6828), [[2]](https://github.com/better-auth/better-auth/issues/6671). Exploring these might give you further insights. Please feel free to share any additional details or ask more questions if you need help investigating this further! _If you need more help, tag @better-auth-agent in a comment so I can respond._ <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) • [Discord](https://discord.gg/fG2XXEuQX3) • [GitHub](https://github.com/Skyvern-AI/Skyvern) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/fG2XXEuQX3) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/Skyvern-AI/Skyvern)
Author
Owner

@dosubot[bot] commented on GitHub (Jan 6, 2026):

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

Your 404 and invalid_code errors are almost certainly due to how Better Auth expects OAuth callbacks to be routed and how state/cookies are handled in custom backend setups.

In Better Auth v1.4.6+, the OAuth callback must be accessible at /api/auth/callback/figma and routed to the built-in Better Auth handler—not a custom controller. If you only call auth.api.* methods in your own routes and don't expose the built-in callback endpoint, the token exchange will fail, resulting in the errors you see. The callback handler uses the baseURL and basePath from your config to construct the redirect URI, and this must match exactly what is registered with Figma and what is actually exposed by your backend. Any mismatch will cause the code exchange to fail and return invalid_code or a 404 error from the provider [source].

To fix this, in your main.ts, mount the Better Auth handler directly on the Express instance with:

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

This ensures all /api/auth/* routes—including the OAuth callback—are handled by Better Auth as expected [source].

Also, double-check that:

  • The redirect URI registered in Figma is exactly https://your-domain.com/api/auth/callback/figma (including protocol, domain, and path).
  • Your Better Auth baseURL and basePath config match the actual route exposed by your backend.
  • You are not overriding the callback logic with a custom controller—let the built-in handler process the callback.
  • If you must use custom backend routes, you must forward all Set-Cookie headers from Better Auth responses to the browser, or the state cookie will be missing and the callback will fail [source].

If you follow these steps, the 404 and invalid_code errors should be resolved. If you still see issues, enable debug logs and check for cookie or redirect URI mismatches in the request/response flow.

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

<!-- gh-comment-id:3716025022 --> @dosubot[bot] commented on GitHub (Jan 6, 2026): <!-- Greeting --> Hi @Muhammed21! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> Your 404 and `invalid_code` errors are almost certainly due to how Better Auth expects OAuth callbacks to be routed and how state/cookies are handled in custom backend setups. In Better Auth v1.4.6+, the OAuth callback must be accessible at `/api/auth/callback/figma` and routed to the built-in Better Auth handler—not a custom controller. If you only call `auth.api.*` methods in your own routes and don't expose the built-in callback endpoint, the token exchange will fail, resulting in the errors you see. The callback handler uses the `baseURL` and `basePath` from your config to construct the redirect URI, and this must match exactly what is registered with Figma and what is actually exposed by your backend. Any mismatch will cause the code exchange to fail and return `invalid_code` or a 404 error from the provider [[source](https://github.com/better-auth/better-auth/issues/6828)]. To fix this, in your `main.ts`, mount the Better Auth handler directly on the Express instance with: ```ts const express = app.getHttpAdapter().getInstance(); express.all(/^\/api\/auth\/.*$/, toNodeHandler(auth)); ``` This ensures all `/api/auth/*` routes—including the OAuth callback—are handled by Better Auth as expected [[source](https://github.com/better-auth/better-auth/issues/6636)]. Also, double-check that: - The redirect URI registered in Figma is exactly `https://your-domain.com/api/auth/callback/figma` (including protocol, domain, and path). - Your Better Auth `baseURL` and `basePath` config match the actual route exposed by your backend. - You are not overriding the callback logic with a custom controller—let the built-in handler process the callback. - If you must use custom backend routes, you must forward all `Set-Cookie` headers from Better Auth responses to the browser, or the state cookie will be missing and the callback will fail [[source](https://github.com/better-auth/better-auth/issues/7034)]. If you follow these steps, the 404 and `invalid_code` errors should be resolved. If you still see issues, enable debug logs and check for cookie or redirect URI mismatches in the request/response flow. <!-- 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/7f0418ca-ee3d-41b0-848e-a58bdb4dfa3b?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/7f0418ca-ee3d-41b0-848e-a58bdb4dfa3b?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/7f0418ca-ee3d-41b0-848e-a58bdb4dfa3b?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/7f0418ca-ee3d-41b0-848e-a58bdb4dfa3b?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/7f0418ca-ee3d-41b0-848e-a58bdb4dfa3b?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/7f0418ca-ee3d-41b0-848e-a58bdb4dfa3b?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/7f0418ca-ee3d-41b0-848e-a58bdb4dfa3b?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=Your%20404%20and%20%60invalid_code%60%20errors%20are%20almost%20certainly%20due%20to%20how%20Better%20Auth%20expects%20OAuth%20callbacks%20to%20be%20routed%20and%20how%20state/cookies%20are%20handled%20in%20custom%20backend%20setups.%0A%0AIn%20Better%20Auth%20v1.4.6%2B%2C%20the%20OAuth%20callback%20must%20be%20accessible%20at%20%60/api/auth/callback/figma%60%20and%20routed%20to%20the%20built-in%20Better%20Auth%20handler%E2%80%94not%20a%20custom%20controller.%20If%20you%20only%20call%20%60auth.api.%2A%60%20methods%20in%20your%20own%20routes%20and%20don%27t%20expose%20the%20built-in%20callback%20endpoint%2C%20the%20token%20exchange%20will%20fail%2C%20resulting%20in%20the%20errors%20you%20see.%20The%20callback%20handler%20uses%20the%20%60baseURL%60%20and%20%60basePath%60%20from%20your%20config%20to%20construct%20the%20redirect%20URI%2C%20and%20this%20must%20match%20exactly%20what%20is%20registered%20with%20Figma%20and%20what%20is%20actually%20exposed%20by%20your%20backend.%20Any%20mismatch%20will%20cause%20the%20code%20exchange%20to%20fail%20and%20return%20%60invalid_code%60%20or%20a%20404%20error%20from%20the%20provider%20%5B%5Bsource%5D%28https%3A//github.com/better-auth/better-auth/issues/6828%29%5D.%0A%0ATo%20fix%20this%2C%20in%20your%20%60main.ts%60%2C%20mount%20the%20Better%20Auth%20handler%20directly%20on%20the%20Express%20instance%20with%3A%0A%0A%60%60%60ts%0Aconst%20express%20%3D%20app.getHttpAdapter%28%29.getInstance%28%29%3B%0Aexpress.all%28/%5E%5C/api%5C/auth%5C/.%2A%24/%2C%20toNodeHandler%28auth%29%29%3B%0A%60%60%60%0A%0AThis%20ensures%20all%20%60/api/auth/%2A%60%20routes%E2%80%94including%20the%20OAuth%20callback%E2%80%94are%20handled%20by%20Better%20Auth%20as%20expected%20%5B%5Bsource%5D%28https%3A//github.com/better-auth/better-auth/issues/6636%29%5D.%0A%0AAlso%2C%20double-check%20that%3A%0A-%20The%20redirect%20URI%20registered%20in%20Figma%20is%20exactly%20%60https%3A//your-domain.com/api/auth/callback/figma%60%20%28including%20protocol%2C%20domain%2C%20and%20path%29.%0A-%20Your%20Better%20Auth%20%60baseURL%60%20and%20%60basePath%60%20config%20match%20the%20actual%20route%20exposed%20by%20your%20backend.%0A-%20You%20are%20not%20overriding%20the%20callback%20logic%20with%20a%20custom%20controller%E2%80%94let%20the%20built-in%20handler%20process%20the%20callback.%0A-%20If%20you%20must%20use%20custom%20backend%20routes%2C%20you%20must%20forward%20all%20%60Set-Cookie%60%20headers%20from%20Better%20Auth%20responses%20to%20the%20browser%2C%20or%20the%20state%20cookie%20will%20be%20missing%20and%20the%20callback%20will%20fail%20%5B%5Bsource%5D%28https%3A//github.com/better-auth/better-auth/issues/7034%29%5D.%0A%0AIf%20you%20follow%20these%20steps%2C%20the%20404%20and%20%60invalid_code%60%20errors%20should%20be%20resolved.%20If%20you%20still%20see%20issues%2C%20enable%20debug%20logs%20and%20check%20for%20cookie%20or%20redirect%20URI%20mismatches%20in%20the%20request/response%20flow.)&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/7153)
Author
Owner

@Muhammed21 commented on GitHub (Jan 6, 2026):

Image

Here is my new main.ts file, however I still get error 404. I also tried calling /api/auth/sign-in/social directly from the frontend without going through my custom route, and even that returns a 404 error.
The FIGMA_REDIRECT_URI key of my .env is http://localhost:8080/api/auth/callback/figma

import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ZodValidationFilter } from './shared/presentation/filters/zod-validation.filter';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { toNodeHandler } from 'better-auth/node';
import cookieParser from 'cookie-parser';

async function bootstrap() {
  const app = await NestFactory.create(AppModule, {
    bodyParser: false, // Enable body parsing
  });

  app.enableCors({
    origin: process.env.CLIENT_URL || 'http://localhost:3000',
    credentials: true,
    methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
    allowedHeaders: ['Content-Type', 'Authorization', 'Cookie'],
    exposedHeaders: ['Set-Cookie'],
  });

  const auth = app.get('AUTH_INSTANCE');
  const API_VERSION = process.env.API_VERSION ?? 'v1';
  const express = app.getHttpAdapter().getInstance();

  express.all(/^\/api\/auth\/.*$/, toNodeHandler(auth));

  app.use(cookieParser());
  app.setGlobalPrefix(`api/${API_VERSION}`);
  app.useGlobalFilters(new ZodValidationFilter());

  const config = new DocumentBuilder()
    .addBearerAuth()
    .setTitle('Desyn Gateway API')
    .setDescription(`API documentation for ${API_VERSION} of Desyn Gateway`)
    .setVersion('1.0')
    .build();
  const documentFactory = () => SwaggerModule.createDocument(app, config);
  SwaggerModule.setup(`api/${API_VERSION}`, app, documentFactory);

  await app.listen(process.env.PORT ?? 8080);
}

bootstrap();

<!-- gh-comment-id:3716128651 --> @Muhammed21 commented on GitHub (Jan 6, 2026): <img width="451" height="188" alt="Image" src="https://github.com/user-attachments/assets/c4c56d23-fa21-4726-8494-9919d824bcff" /> Here is my new main.ts file, however I still get **error 404**. I also tried calling `/api/auth/sign-in/social `directly from the frontend without going through my custom route, and even that returns a **404 error.** The **_FIGMA_REDIRECT_URI_** key of my `.env` is `http://localhost:8080/api/auth/callback/figma` ```ts import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; import { ZodValidationFilter } from './shared/presentation/filters/zod-validation.filter'; import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; import { toNodeHandler } from 'better-auth/node'; import cookieParser from 'cookie-parser'; async function bootstrap() { const app = await NestFactory.create(AppModule, { bodyParser: false, // Enable body parsing }); app.enableCors({ origin: process.env.CLIENT_URL || 'http://localhost:3000', credentials: true, methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'], allowedHeaders: ['Content-Type', 'Authorization', 'Cookie'], exposedHeaders: ['Set-Cookie'], }); const auth = app.get('AUTH_INSTANCE'); const API_VERSION = process.env.API_VERSION ?? 'v1'; const express = app.getHttpAdapter().getInstance(); express.all(/^\/api\/auth\/.*$/, toNodeHandler(auth)); app.use(cookieParser()); app.setGlobalPrefix(`api/${API_VERSION}`); app.useGlobalFilters(new ZodValidationFilter()); const config = new DocumentBuilder() .addBearerAuth() .setTitle('Desyn Gateway API') .setDescription(`API documentation for ${API_VERSION} of Desyn Gateway`) .setVersion('1.0') .build(); const documentFactory = () => SwaggerModule.createDocument(app, config); SwaggerModule.setup(`api/${API_VERSION}`, app, documentFactory); await app.listen(process.env.PORT ?? 8080); } bootstrap(); ```
Author
Owner

@dosubot[bot] commented on GitHub (Jan 6, 2026):

Your 404 errors are happening because setGlobalPrefix in NestJS adds a prefix (like /api/v1) to all controller routes, but it does NOT affect routes mounted directly on the Express instance. So, mounting toNodeHandler on /^/api/auth/.$/ only matches /api/auth/, not /api/v1/api/auth/, which is what your app is actually exposing due to the global prefix. This means requests to /api/auth/ never reach Better Auth—they 404 instead [source].

To fix this, change your handler mount to match the full prefixed path:

express.all(/^\/api\/v1\/auth\/.*$/, toNodeHandler(auth));

If your API_VERSION changes, use:

express.all(new RegExp(`^/api/${API_VERSION}/auth/.*$`), toNodeHandler(auth));

This ensures all /api/v1/auth/* routes—including /api/v1/auth/sign-in/social and /api/v1/auth/callback/figma—are handled by Better Auth as expected [source].

Make sure this line runs before any other middleware that could intercept the request. If you still get 404s, double-check that auth is a valid Better Auth instance and that your baseURL/basePath config matches the actual exposed route.

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

<!-- gh-comment-id:3716149390 --> @dosubot[bot] commented on GitHub (Jan 6, 2026): <!-- Answer --> Your 404 errors are happening because setGlobalPrefix in NestJS adds a prefix (like /api/v1) to all controller routes, but it does NOT affect routes mounted directly on the Express instance. So, mounting toNodeHandler on /^\/api\/auth\/.*$/ only matches /api/auth/*, not /api/v1/api/auth/*, which is what your app is actually exposing due to the global prefix. This means requests to /api/auth/* never reach Better Auth—they 404 instead [[source](https://github.com/better-auth/better-auth/issues/6636)]. To fix this, change your handler mount to match the full prefixed path: ```ts express.all(/^\/api\/v1\/auth\/.*$/, toNodeHandler(auth)); ``` If your API_VERSION changes, use: ```ts express.all(new RegExp(`^/api/${API_VERSION}/auth/.*$`), toNodeHandler(auth)); ``` This ensures all /api/v1/auth/* routes—including /api/v1/auth/sign-in/social and /api/v1/auth/callback/figma—are handled by Better Auth as expected [[source](https://github.com/better-auth/better-auth/issues/6828)]. Make sure this line runs before any other middleware that could intercept the request. If you still get 404s, double-check that auth is a valid Better Auth instance and that your baseURL/basePath config matches the actual exposed route. <!-- 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/3b5e017c-c1e7-4404-a313-51721e6bc8ac?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/3b5e017c-c1e7-4404-a313-51721e6bc8ac?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/3b5e017c-c1e7-4404-a313-51721e6bc8ac?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/3b5e017c-c1e7-4404-a313-51721e6bc8ac?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/3b5e017c-c1e7-4404-a313-51721e6bc8ac?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/3b5e017c-c1e7-4404-a313-51721e6bc8ac?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/3b5e017c-c1e7-4404-a313-51721e6bc8ac?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=Your%20404%20errors%20are%20happening%20because%20setGlobalPrefix%20in%20NestJS%20adds%20a%20prefix%20%28like%20/api/v1%29%20to%20all%20controller%20routes%2C%20but%20it%20does%20NOT%20affect%20routes%20mounted%20directly%20on%20the%20Express%20instance.%20So%2C%20mounting%20toNodeHandler%20on%20/%5E%5C/api%5C/auth%5C/.%2A%24/%20only%20matches%20/api/auth/%2A%2C%20not%20/api/v1/api/auth/%2A%2C%20which%20is%20what%20your%20app%20is%20actually%20exposing%20due%20to%20the%20global%20prefix.%20This%20means%20requests%20to%20/api/auth/%2A%20never%20reach%20Better%20Auth%E2%80%94they%20404%20instead%20%5B%5Bsource%5D%28https%3A//github.com/better-auth/better-auth/issues/6636%29%5D.%0A%0ATo%20fix%20this%2C%20change%20your%20handler%20mount%20to%20match%20the%20full%20prefixed%20path%3A%0A%0A%60%60%60ts%0Aexpress.all%28/%5E%5C/api%5C/v1%5C/auth%5C/.%2A%24/%2C%20toNodeHandler%28auth%29%29%3B%0A%60%60%60%0A%0AIf%20your%20API_VERSION%20changes%2C%20use%3A%0A%0A%60%60%60ts%0Aexpress.all%28new%20RegExp%28%60%5E/api/%24%7BAPI_VERSION%7D/auth/.%2A%24%60%29%2C%20toNodeHandler%28auth%29%29%3B%0A%60%60%60%0A%0AThis%20ensures%20all%20/api/v1/auth/%2A%20routes%E2%80%94including%20/api/v1/auth/sign-in/social%20and%20/api/v1/auth/callback/figma%E2%80%94are%20handled%20by%20Better%20Auth%20as%20expected%20%5B%5Bsource%5D%28https%3A//github.com/better-auth/better-auth/issues/6828%29%5D.%0A%0AMake%20sure%20this%20line%20runs%20before%20any%20other%20middleware%20that%20could%20intercept%20the%20request.%20If%20you%20still%20get%20404s%2C%20double-check%20that%20auth%20is%20a%20valid%20Better%20Auth%20instance%20and%20that%20your%20baseURL/basePath%20config%20matches%20the%20actual%20exposed%20route.)&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/7153)
Author
Owner

@Muhammed21 commented on GitHub (Jan 6, 2026):

No, when I do that, my local routes conflict with the BetterAuth routes, so it displays a 404 Not Found error. That's not the solution; I want a real member of the team to help me.

@better-auth-agent

<!-- gh-comment-id:3716196199 --> @Muhammed21 commented on GitHub (Jan 6, 2026): No, when I do that, my local routes conflict with the BetterAuth routes, so it displays a 404 Not Found error. That's not the solution; I want a real member of the team to help me. @better-auth-agent
Author
Owner

@better-auth-agent[bot] commented on GitHub (Jan 6, 2026):

It looks like you're encountering a 404 error after the Figma OAuth callback. This issue might be related to a misconfiguration in your routes or the way Better Auth is integrated.

From previous discussions, there have been mentions of similar 404 issues occurring when routes are not set up correctly. A possible solution could involve checking that the redirect URI for Figma matches what is configured in your application and in the Figma app settings. Ensure that /api/auth/callback/figma is correctly routed in your backend.

Also, check if the Base URL is set properly in the Better Auth configuration, as it needs to be consistent for the OAuth flow to succeed.

If the issue persists, it might be beneficial to raise it in detail with the Better Auth team, tagging @bekacru and @ping__, for further assistance.

Have you verified that the redirect URI settings in your Figma app configuration align with your application routing?

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3716196849 --> @better-auth-agent[bot] commented on GitHub (Jan 6, 2026): It looks like you're encountering a 404 error after the Figma OAuth callback. This issue might be related to a misconfiguration in your routes or the way Better Auth is integrated. From previous discussions, there have been mentions of similar 404 issues occurring when routes are not set up correctly. A possible solution could involve checking that the redirect URI for Figma matches what is configured in your application and in the Figma app settings. Ensure that `/api/auth/callback/figma` is correctly routed in your backend. Also, check if the Base URL is set properly in the Better Auth configuration, as it needs to be consistent for the OAuth flow to succeed. If the issue persists, it might be beneficial to raise it in detail with the Better Auth team, tagging @bekacru and @ping__, for further assistance. Have you verified that the redirect URI settings in your Figma app configuration align with your application routing? <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) • [Discord](https://discord.gg/fG2XXEuQX3) • [GitHub](https://github.com/Skyvern-AI/Skyvern) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/fG2XXEuQX3) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/Skyvern-AI/Skyvern)
Author
Owner

@Muhammed21 commented on GitHub (Jan 6, 2026):

Can you help me? @Bekacru @ping__

<!-- gh-comment-id:3716568415 --> @Muhammed21 commented on GitHub (Jan 6, 2026): Can you help me? @Bekacru @ping__
Author
Owner

@bytaesu commented on GitHub (Jan 7, 2026):

Hi @Muhammed21,

I'm checking this 🤓

<!-- gh-comment-id:3717788177 --> @bytaesu commented on GitHub (Jan 7, 2026): Hi @Muhammed21, I'm checking this 🤓
Author
Owner

@bytaesu commented on GitHub (Jan 7, 2026):

Hi @Muhammed21,

I’ve looked into the issue and listed my thoughts:

  • Are you using NextJS integration?
  • You don't need to set figma.redirectURI. In most cases, Better Auth handles it automatically.
  • You've disabled disableDefaultScope, but the scopes you need haven't been set.
  • If directly calling /api/auth/sign-in/social returns a 404, the route may not be mounted correctly.

If the problem persists, could you provide more details? I haven't worked with NestJS in depth, so I'll need more info to investigate 🙏

<!-- gh-comment-id:3717865284 --> @bytaesu commented on GitHub (Jan 7, 2026): Hi @Muhammed21, I’ve looked into the issue and listed my thoughts: - Are you using [NextJS integration](https://www.better-auth.com/docs/integrations/nestjs)? - You don't need to set `figma.redirectURI`. In most cases, Better Auth handles it automatically. - You've disabled `disableDefaultScope`, but the scopes you need haven't been set. - If directly calling `/api/auth/sign-in/social` returns a 404, the route may not be mounted correctly. If the problem persists, could you provide more details? I haven't worked with NestJS in depth, so I'll need more info to investigate 🙏
Author
Owner

@Muhammed21 commented on GitHub (Jan 7, 2026):

Hi @bytaesu,

Yes, I’m using the NextJS integration from Better Auth:
https://www.better-auth.com/docs/integrations/nestjs

I’ve tried several times to configure only the redirect URL in the Figma Dashboard, but the result was never successful.
I disabled the default scope becausefile_readis deprecated and was causing an invalid_scope error when calling the API.

The scopes are now properly defined in the signIn service, right below the @Injectable() decorator.
However, even when testing the API via /api/auth/reference, I get a 404 error once the callback is validated.

I can’t figure out which URL is causing this issue, nor which URL the user is being redirected to after the callback is successfully validated.

<!-- gh-comment-id:3718657766 --> @Muhammed21 commented on GitHub (Jan 7, 2026): Hi @bytaesu, Yes, I’m using the **NextJS integration** from Better Auth: https://www.better-auth.com/docs/integrations/nestjs I’ve tried several times to configure only the redirect URL in the **Figma Dashboard**, but the result was never successful. I disabled the default scope because` file_read `is deprecated and was causing an` invalid_scope` error when calling the API. The scopes are now properly defined in the `signIn` service, right below the `@Injectable() `decorator. However, even when testing the API via `/api/auth/reference`, I get a **404 error** once the callback is validated. I can’t figure out which URL is causing this issue, nor which URL the user is being redirected to after the callback is successfully validated.
Author
Owner

@Muhammed21 commented on GitHub (Jan 7, 2026):

Here is my auth.module.ts

import { Module } from '@nestjs/common';
import { createAuth } from '../auth/infrastructure/betterAuth/auth';
import { SessionMethodeRepository } from '../auth/core/application/port/session-methode.repository';
import { SessionRepository } from '../auth/infrastructure/betterAuth/session-repository.service';
import { GetSessionUseCase } from '../auth/core/application/useCases/get-session.use-case';
import { SignOutUseCase } from '../auth/core/application/useCases/sign-out.use-case';
import { AuthController } from '../auth/presentation/auth.controller';
import { SingInUseCase } from '../auth/core/application/useCases/sing-in.use-case';
import { PrismaService } from '../../prisma/prisma.service';
import { AUTH_INSTANCE } from '../auth/infrastructure/betterAuth/auth.constant';
import { PrismaModule } from '../../prisma/prisma.module';
import { AuthModule } from '@thallesp/nestjs-better-auth';

@Module({
  imports: [
    PrismaModule,
    AuthModule.forRootAsync({
      imports: [PrismaModule],
      inject: [PrismaService],
      useFactory: (prisma: PrismaService) => ({
        auth: createAuth(prisma),
      }),
    }),
  ],
  controllers: [AuthController],
  providers: [
    {
      provide: AUTH_INSTANCE,
      useFactory: (prisma: PrismaService) => {
        return createAuth(prisma);
      },
      inject: [PrismaService],
    },
    GetSessionUseCase,
    SignOutUseCase,
    SingInUseCase,
    {
      provide: SessionMethodeRepository,
      useClass: SessionRepository,
    },
  ],
  exports: [SessionMethodeRepository, AUTH_INSTANCE],
})
export class AuthenticationModule {}


At this point, I properly set up the scope and callbackURL

@Injectable()
export class SessionRepository implements SessionMethodeRepository {
  constructor(
    @Inject(AUTH_INSTANCE) private readonly auth: Auth,
    private readonly authService: AuthService<typeof auth>,
  ) {}

  async signIn(query: SignInQuery): Promise<Response> {
    const headers = query.headers;
    return await this.authService.api.signInSocial({
      body: {
        provider: query.provider,
        scopes: ['file_content:read'],
        callbackURL: process.env.FIGMA_REDIRECT_URI,
      },
      headers,
      asResponse: true,
    });
  }


And in the controller, I'm sending the headers like this; I don't know if it's the best way, but it seems to work.

  @Post('sign-in')
  @UsePipes(new ZodValidationPipe(signInSchema))
  async signIn(
    @Body() body: SignInQueryHttpDTO,
    @Req() req: Request,
    @Res() res: Response,
  ): Promise<void> {
    const domainQuery = SignInQuery.create(body.provider, req.headers);
    const result = await this.repository.signIn(domainQuery);

    res.status(result.status);

    result.headers.forEach((value, key) => {
      res.setHeader(key, value);
    });

    const buffer = Buffer.from(await result.arrayBuffer());
    res.send(buffer);
  }
<!-- gh-comment-id:3718668682 --> @Muhammed21 commented on GitHub (Jan 7, 2026): Here is my auth.module.ts ```ts import { Module } from '@nestjs/common'; import { createAuth } from '../auth/infrastructure/betterAuth/auth'; import { SessionMethodeRepository } from '../auth/core/application/port/session-methode.repository'; import { SessionRepository } from '../auth/infrastructure/betterAuth/session-repository.service'; import { GetSessionUseCase } from '../auth/core/application/useCases/get-session.use-case'; import { SignOutUseCase } from '../auth/core/application/useCases/sign-out.use-case'; import { AuthController } from '../auth/presentation/auth.controller'; import { SingInUseCase } from '../auth/core/application/useCases/sing-in.use-case'; import { PrismaService } from '../../prisma/prisma.service'; import { AUTH_INSTANCE } from '../auth/infrastructure/betterAuth/auth.constant'; import { PrismaModule } from '../../prisma/prisma.module'; import { AuthModule } from '@thallesp/nestjs-better-auth'; @Module({ imports: [ PrismaModule, AuthModule.forRootAsync({ imports: [PrismaModule], inject: [PrismaService], useFactory: (prisma: PrismaService) => ({ auth: createAuth(prisma), }), }), ], controllers: [AuthController], providers: [ { provide: AUTH_INSTANCE, useFactory: (prisma: PrismaService) => { return createAuth(prisma); }, inject: [PrismaService], }, GetSessionUseCase, SignOutUseCase, SingInUseCase, { provide: SessionMethodeRepository, useClass: SessionRepository, }, ], exports: [SessionMethodeRepository, AUTH_INSTANCE], }) export class AuthenticationModule {} ``` --- At this point, I properly set up the scope and callbackURL ```ts @Injectable() export class SessionRepository implements SessionMethodeRepository { constructor( @Inject(AUTH_INSTANCE) private readonly auth: Auth, private readonly authService: AuthService<typeof auth>, ) {} async signIn(query: SignInQuery): Promise<Response> { const headers = query.headers; return await this.authService.api.signInSocial({ body: { provider: query.provider, scopes: ['file_content:read'], callbackURL: process.env.FIGMA_REDIRECT_URI, }, headers, asResponse: true, }); } ``` --- And in the controller, I'm sending the headers like this; I don't know if it's the best way, but it seems to work. ```ts @Post('sign-in') @UsePipes(new ZodValidationPipe(signInSchema)) async signIn( @Body() body: SignInQueryHttpDTO, @Req() req: Request, @Res() res: Response, ): Promise<void> { const domainQuery = SignInQuery.create(body.provider, req.headers); const result = await this.repository.signIn(domainQuery); res.status(result.status); result.headers.forEach((value, key) => { res.setHeader(key, value); }); const buffer = Buffer.from(await result.arrayBuffer()); res.send(buffer); } ```
Author
Owner

@bytaesu commented on GitHub (Jan 7, 2026):

I'm thinking this probably related to these

<!-- gh-comment-id:3720859496 --> @bytaesu commented on GitHub (Jan 7, 2026): I'm thinking this probably related to these - https://github.com/better-auth/better-call/pull/93 - https://github.com/ThallesP/nestjs-better-auth/issues/85
Author
Owner

@Muhammed21 commented on GitHub (Jan 7, 2026):

No @bytaesu , all the Better-Auth routes work for me; I just can't understand why I get a 404 error after being redirected to the callback following the granting of access via the Figma page.


Image

https://github.com/user-attachments/assets/e5906bd6-207b-481e-83f2-278c5f53ee14

<!-- gh-comment-id:3720973837 --> @Muhammed21 commented on GitHub (Jan 7, 2026): No @bytaesu , all the Better-Auth routes work for me; I just can't understand why I get a 404 error after being redirected to the callback following the granting of access via the Figma page. --- <img width="930" height="464" alt="Image" src="https://github.com/user-attachments/assets/487b448f-9ed3-440e-8046-00f6e69c119f" /> --- https://github.com/user-attachments/assets/e5906bd6-207b-481e-83f2-278c5f53ee14
Author
Owner

@Muhammed21 commented on GitHub (Jan 9, 2026):

@Bekacru @bytaesu Do you have the solution ?

<!-- gh-comment-id:3728080237 --> @Muhammed21 commented on GitHub (Jan 9, 2026): @Bekacru @bytaesu Do you have the solution ?
Author
Owner

@bytaesu commented on GitHub (Jan 9, 2026):

Hi @Muhammed21,

Could you share a minimal, reproducible public repo with me?
I don't have much experience with NestJS, and we don't yet provide official NestJS integration.
If you can share one, I'd like to take a look and help you 🙏

<!-- gh-comment-id:3728356313 --> @bytaesu commented on GitHub (Jan 9, 2026): Hi @Muhammed21, Could you share a minimal, reproducible public repo with me? I don't have much experience with NestJS, and we don't yet provide official NestJS integration. If you can share one, I'd like to take a look and help you 🙏
Author
Owner

@Muhammed21 commented on GitHub (Jan 9, 2026):

Hi @bytaesu

No problem, I've invited you to the main repository, thank you for helping me.

<!-- gh-comment-id:3728697258 --> @Muhammed21 commented on GitHub (Jan 9, 2026): Hi @bytaesu No problem, I've invited you to the main repository, thank you for helping me.
Author
Owner

@Muhammed21 commented on GitHub (Jan 9, 2026):

@bytaesu You will find all the information you need about the architecture, as well as a complete list of the available CLI commands to start both the backend and the frontend. Contact me if needed.

<!-- gh-comment-id:3728917999 --> @Muhammed21 commented on GitHub (Jan 9, 2026): @bytaesu You will find all the information you need about the architecture, as well as a complete list of the available CLI commands to start both the backend and the frontend. Contact me if needed.
Author
Owner

@Muhammed21 commented on GitHub (Jan 12, 2026):

@Bekacru @bytaesu Do you have the solution ?

<!-- gh-comment-id:3740294711 --> @Muhammed21 commented on GitHub (Jan 12, 2026): @Bekacru @bytaesu Do you have the solution ?
Author
Owner

@bytaesu commented on GitHub (Jan 13, 2026):

Hi @Muhammed21,

Sorry for the delay. Could you share a minimal, reproducible repo? I’m not very familiar with NestJS, and it would help me quickly identify the issue.

The repo you invited me to is quite large.. so it would take too long to go through in detail 🙏

<!-- gh-comment-id:3744805867 --> @bytaesu commented on GitHub (Jan 13, 2026): Hi @Muhammed21, Sorry for the delay. Could you share a minimal, reproducible repo? I’m not very familiar with NestJS, and it would help me quickly identify the issue. The repo you invited me to is quite large.. so it would take too long to go through in detail 🙏
Author
Owner

@Muhammed21 commented on GitHub (Jan 16, 2026):

Hi @bytaesu

I'm going to try to make it for you

<!-- gh-comment-id:3760576970 --> @Muhammed21 commented on GitHub (Jan 16, 2026): Hi @bytaesu I'm going to try to make it for you
Author
Owner

@bytaesu commented on GitHub (Jan 16, 2026):

Thanks @Muhammed21,

Even a very simple setup is fine, as long as the bug is reproducible!

That would be a big help in resolving the issue 🙏🙏

<!-- gh-comment-id:3761092098 --> @bytaesu commented on GitHub (Jan 16, 2026): Thanks @Muhammed21, Even a very simple setup is fine, as long as the bug is reproducible! That would be a big help in resolving the issue 🙏🙏
Author
Owner

@Muhammed21 commented on GitHub (Jan 16, 2026):

No problem @bytaesu

Here is the repository link for the nestjs_better-auth template where the bug occurs:
https://github.com/Muhammed21/nestjs_better-auth_template/tree/main

All the necessary information can be found in the README.md file.

I hope you’ll be able to help me and find a solution to the issue with the Figma provider.

<!-- gh-comment-id:3761271648 --> @Muhammed21 commented on GitHub (Jan 16, 2026): No problem @bytaesu Here is the repository **link** for the **nestjs_better-auth** template where the **bug occurs**: https://github.com/Muhammed21/nestjs_better-auth_template/tree/main All the necessary information can be found in the README.md file. I hope you’ll be able to help me and find a **solution** to the issue with the **Figma** provider.
Author
Owner

@bytaesu commented on GitHub (Jan 16, 2026):

Hey @Muhammed21,

Thanks for letting me know!
I just noticed issue, and opened PR 🙏

<!-- gh-comment-id:3761786197 --> @bytaesu commented on GitHub (Jan 16, 2026): Hey @Muhammed21, Thanks for letting me know! I just noticed issue, and opened PR 🙏
Author
Owner

@bytaesu commented on GitHub (Jan 16, 2026):

Ok, I confirmed it works with your app 🙌
I'll merge this

<!-- gh-comment-id:3761802374 --> @bytaesu commented on GitHub (Jan 16, 2026): Ok, I confirmed it works with your app 🙌 I'll merge this
Author
Owner

@Muhammed21 commented on GitHub (Jan 16, 2026):

Thank you very much @bytaesu , I'll check it out.

<!-- gh-comment-id:3761864009 --> @Muhammed21 commented on GitHub (Jan 16, 2026): Thank you very much @bytaesu , I'll check it out.
Author
Owner

@Muhammed21 commented on GitHub (Jan 16, 2026):

@bytaesu Do I need to perform any action to update to the new version of better-auth in my repository?

<!-- gh-comment-id:3761894040 --> @Muhammed21 commented on GitHub (Jan 16, 2026): @bytaesu Do I need to perform any action to update to the new version of better-auth in my repository?
Author
Owner

@bytaesu commented on GitHub (Jan 16, 2026):

@bytaesu Do I need to perform any action to update to the new version of better-auth in my repository?

Nope, with the current setup, there’s nothing to migrate! You can also use the version below immediately before the new release 🙂

+) DIRECT_URL is deprecated in Prisma v7

npm i https://pkg.pr.new/better-auth/better-auth@7422
<!-- gh-comment-id:3761924770 --> @bytaesu commented on GitHub (Jan 16, 2026): > [@bytaesu](https://github.com/bytaesu) Do I need to perform any action to update to the new version of better-auth in my repository? Nope, with the current setup, there’s nothing to migrate! You can also use the version below immediately before the new release 🙂 +) `DIRECT_URL` is deprecated in Prisma v7 ``` npm i https://pkg.pr.new/better-auth/better-auth@7422 ```
Author
Owner

@bytaesu commented on GitHub (Jan 16, 2026):

And If you use disableDefaultScope, all the defaults are removed, so you’ll need to add them yourself.

<!-- gh-comment-id:3761927936 --> @bytaesu commented on GitHub (Jan 16, 2026): And If you use `disableDefaultScope`, all the defaults are removed, so you’ll need to add them yourself.
Author
Owner

@Muhammed21 commented on GitHub (Jan 16, 2026):

Everything is working on my end, thank you so much for the tips!

<!-- gh-comment-id:3761985547 --> @Muhammed21 commented on GitHub (Jan 16, 2026): Everything is working on my end, thank you so much for the tips!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#28071