From a59c092172fd523e1b0565dd9ec544baf3ca9fa6 Mon Sep 17 00:00:00 2001 From: bananabas Date: Mon, 13 Apr 2026 18:38:46 +0100 Subject: [PATCH] Fix: Configure passkey RPID and origin Set `rpID` and `rpName` for passkey authentication. This is crucial for WebAuthn to correctly identify the relying party and establish secure credentials. Additionally, set the `origin` to ensure consistent communication between the client and server during passkey operations. --- apps/api/lib/auth.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/api/lib/auth.ts b/apps/api/lib/auth.ts index 33cb200..9db6536 100644 --- a/apps/api/lib/auth.ts +++ b/apps/api/lib/auth.ts @@ -1,8 +1,9 @@ import { betterAuth } from 'better-auth'; import { organization, magicLink } from 'better-auth/plugins'; -import { passkey } from '@better-auth/passkey'; // separate package! +import { passkey } from '@better-auth/passkey'; import { drizzleAdapter } from 'better-auth/adapters/drizzle'; import { db } from '@/db'; +import * as schema from '@/db/schema'; const baseURL = process.env.BETTER_AUTH_URL || 'http://localhost:3001'; @@ -10,13 +11,18 @@ export const auth = betterAuth({ baseURL, database: drizzleAdapter(db, { provider: 'pg', + schema, }), emailAndPassword: { enabled: true, }, plugins: [ organization(), - passkey(), + passkey({ + rpID: new URL(baseURL).hostname, + rpName: 'Bagsy', + origin: baseURL, + }), magicLink({ sendMagicLink: async ({ email, url }) => { console.log(`Magic link for ${email}: ${url}`);