Automatic db schema generation not working with stripe integration and prisma #763

Closed
opened 2026-03-13 08:03:22 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @mmkaram on GitHub (Mar 2, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Use prisma to manage a db with a nextjs application
add stripe plugin information to auth.ts and auth-client.ts
run npx @better-auth/cli generate

Current vs. Expected behavior

Expected behavior:
make a new schema.prisma file with tables necessary for stripe integration
Current behavior:

2025-03-02T17:57:18.536Z ERROR [Better Auth]: [#better-auth]: Couldn't read your auth config. Error: Neither apiKey nor config.authenticator provided
    at Stripe._setAuthenticator (file:///home/dd0k/prog/site/node_modules/stripe/esm/stripe.core.js:163:23)
    at new Stripe (file:///home/dd0k/prog/site/node_modules/stripe/esm/stripe.core.js:99:14)
    at /home/dd0k/prog/site/lib/auth.ts:9:45
    at async Function.import (/home/dd0k/.npm/_npx/167ca1f116d365e6/node_modules/jiti/dist/jiti.cjs:1:199772)
    at async resolveConfig (file:///home/dd0k/.npm/_npx/167ca1f116d365e6/node_modules/c12/dist/shared/c12.PQMoYrit.mjs:346:18)
    at async loadConfig (file:///home/dd0k/.npm/_npx/167ca1f116d365e6/node_modules/c12/dist/shared/c12.PQMoYrit.mjs:146:23)
    at async getConfig (file:///home/dd0k/.npm/_npx/167ca1f116d365e6/node_modules/@better-auth/cli/dist/index.mjs:234:30)
    at async Command.generateAction (file:///home/dd0k/.npm/_npx/167ca1f116d365e6/node_modules/@better-auth/cli/dist/index.mjs:643:18)

What version of Better Auth are you using?

1.2.1

Provide environment information

"@prisma/client": "^6.3.1",
    "prisma": "^6.3.1",
    "next": "^15.2.0-canary.71",

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 { PrismaClient } from "@prisma/client";

import { stripe as baStripe } from "@better-auth/stripe";

import Stripe from "stripe";

export const stripeClient = new Stripe(
  process.env.STRIPE_SECRET_KEY as string,
  {
    apiVersion: "2025-02-24.acacia",
    typescript: true,
  },
);

const prisma = new PrismaClient();
export const auth = betterAuth({
  database: prismaAdapter(prisma, {
    provider: "postgresql",
  }),
  socialProviders: {
    github: {
      clientId: process.env.AUTH_GITHUB_ID!,
      clientSecret: process.env.AUTH_GITHUB_SECRET!,
    },
    google: {
      clientId: process.env.GOOGLE_CLIENT_ID!,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
    },
  },
  plugins: [
    baStripe({
      stripeClient,
      stripeWebhookSecret: process.env.STRIPE_WEBHOOK_SECRET!,
      createCustomerOnSignUp: true,
      subscription: {
        enabled: true,
        plans: [
          {
            name: "basic",
            priceId: "price_1QxY9oQeJndFgkfkUFjAEnH4",
          },
        ],
      },
    }),
  ],
});

Additional context

All of the env variables I'm using in this file exist in .env.local, I've tripe checked.

Originally created by @mmkaram on GitHub (Mar 2, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Use prisma to manage a db with a nextjs application add stripe plugin information to auth.ts and auth-client.ts run `npx @better-auth/cli generate` ### Current vs. Expected behavior Expected behavior: make a new schema.prisma file with tables necessary for stripe integration Current behavior: ``` 2025-03-02T17:57:18.536Z ERROR [Better Auth]: [#better-auth]: Couldn't read your auth config. Error: Neither apiKey nor config.authenticator provided at Stripe._setAuthenticator (file:///home/dd0k/prog/site/node_modules/stripe/esm/stripe.core.js:163:23) at new Stripe (file:///home/dd0k/prog/site/node_modules/stripe/esm/stripe.core.js:99:14) at /home/dd0k/prog/site/lib/auth.ts:9:45 at async Function.import (/home/dd0k/.npm/_npx/167ca1f116d365e6/node_modules/jiti/dist/jiti.cjs:1:199772) at async resolveConfig (file:///home/dd0k/.npm/_npx/167ca1f116d365e6/node_modules/c12/dist/shared/c12.PQMoYrit.mjs:346:18) at async loadConfig (file:///home/dd0k/.npm/_npx/167ca1f116d365e6/node_modules/c12/dist/shared/c12.PQMoYrit.mjs:146:23) at async getConfig (file:///home/dd0k/.npm/_npx/167ca1f116d365e6/node_modules/@better-auth/cli/dist/index.mjs:234:30) at async Command.generateAction (file:///home/dd0k/.npm/_npx/167ca1f116d365e6/node_modules/@better-auth/cli/dist/index.mjs:643:18) ``` ### What version of Better Auth are you using? 1.2.1 ### Provide environment information ```bash "@prisma/client": "^6.3.1", "prisma": "^6.3.1", "next": "^15.2.0-canary.71", ``` ### 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 { PrismaClient } from "@prisma/client"; import { stripe as baStripe } from "@better-auth/stripe"; import Stripe from "stripe"; export const stripeClient = new Stripe( process.env.STRIPE_SECRET_KEY as string, { apiVersion: "2025-02-24.acacia", typescript: true, }, ); const prisma = new PrismaClient(); export const auth = betterAuth({ database: prismaAdapter(prisma, { provider: "postgresql", }), socialProviders: { github: { clientId: process.env.AUTH_GITHUB_ID!, clientSecret: process.env.AUTH_GITHUB_SECRET!, }, google: { clientId: process.env.GOOGLE_CLIENT_ID!, clientSecret: process.env.GOOGLE_CLIENT_SECRET!, }, }, plugins: [ baStripe({ stripeClient, stripeWebhookSecret: process.env.STRIPE_WEBHOOK_SECRET!, createCustomerOnSignUp: true, subscription: { enabled: true, plans: [ { name: "basic", priceId: "price_1QxY9oQeJndFgkfkUFjAEnH4", }, ], }, }), ], }); ``` ### Additional context All of the env variables I'm using in this file exist in .env.local, I've tripe checked.
GiteaMirror added the bug label 2026-03-13 08:03:22 -05:00
Author
Owner

@mmkaram commented on GitHub (Mar 2, 2025):

the migrate command was looking for env variables in .env and .env.local.

@mmkaram commented on GitHub (Mar 2, 2025): the migrate command was looking for env variables in .env and .env.local.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#763