AutumnA
Autumn5mo ago
2 replies
Raven

Hey guys.

Hey guys.
Is the better-auth integration working properly? I followed the tutorial and getting [Autumn] customerId returned from identify function is undefined
My setup:
auth.ts
export const auth = betterAuth({
  emailAndPassword: {
    enabled: true,
  },
  database: drizzleAdapter(db, {
    provider: "pg",
  }),
  plugins: [
    autumn({
      secretKey: env.AUTUMN_SECRET_KEY,
    }),
  ],
});


layout.tsx
import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";
import { Toaster } from "sonner";
import { AutumnProvider } from "autumn-js/react";
import { env } from "@/lib/env";

export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  return (
    <html lang="cs">
      <body>
        <AutumnProvider
          includeCredentials={true}
          betterAuthUrl={env.NEXT_PUBLIC_BASE_URL}
        >
          {children}
        </AutumnProvider>
        <Toaster />
      </body>
    </html>
  );
}

And in my component I use the useCustomer hook which makes POST to http://localhost:3000/api/auth/autumn/customers and it returns 401 with no_customer_id error
Was this page helpful?