From b4b07f3120ef127ab8bed85c67010df6a011da30 Mon Sep 17 00:00:00 2001 From: Louie Chillingworth <91068036+louiechilli@users.noreply.github.com> Date: Mon, 20 Apr 2026 21:20:23 +0100 Subject: [PATCH] fix: remove duplicate OIDC provider registration in getSocialProviders (#475) The getSocialProviders endpoint was manually pushing "oidc" to the providers array when OIDC env vars are present, but Better Auth already includes the OIDC provider in ctx.context.socialProviders when it is configured. This resulted in ["oidc","oidc"] being returned from /api/auth/social-providers, causing a duplicate provider registration that led to a TypeError: Cannot read properties of null (reading 'id') during the OIDC login callback, preventing all OIDC logins. Fix: remove the manual providers.push("oidc") block as it is redundant. --- packages/auth/src/providers.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/packages/auth/src/providers.ts b/packages/auth/src/providers.ts index 721067bc..703dd7ad 100644 --- a/packages/auth/src/providers.ts +++ b/packages/auth/src/providers.ts @@ -92,14 +92,6 @@ export const socialProvidersPlugin = () => ({ const providers = ctx.context.socialProviders.map((p) => p.id.toLowerCase(), ); - // Add OIDC provider if configured - if ( - process.env.OIDC_CLIENT_ID && - process.env.OIDC_CLIENT_SECRET && - process.env.OIDC_DISCOVERY_URL - ) { - providers.push("oidc"); - } return ctx.json(providers); }, ),