[GH-ISSUE #6724] trustedClients property redirectURLs does not match internal code expectation redirectUrls #27924

Closed
opened 2026-04-17 19:12:56 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @FabianMHz15 on GitHub (Dec 12, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/6724

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Description

When configuring trustedClients in the oidcProvider plugin, the documentation shows using redirectURLs (uppercase "URLs"), but the internal code expects redirectUrls (lowercase "urls"). This causes a runtime error when the authorize endpoint tries to validate the redirect URI.

Steps to Reproduce

  1. Configure oidcProvider with trustedClients:

oidcProvider({
loginPage: '/login',
trustedClients: [
{
clientId: 'my-app',
clientSecret: 'secret',
name: 'My App',
type: 'web',
redirectURLs: ['http://localhost:3001/api/auth/oauth2/callback/sso'], // As shown in docs
disabled: false,
skipConsent: true,
metadata: {},
},
],
})

  1. Attempt to authorize via /oauth2/authorize?client_id=my-app&...
  2. Error occurs:
    TypeError: Cannot read properties of undefined (reading 'find')

Root Cause

In oidc-provider-CDvxiCPp.mjs, the getClient function at line 374-375 returns trusted clients without transformation:

const trustedClient = trustedClients.find((client) => client.clientId === clientId);
if (trustedClient) return trustedClient; // Returns as-is

Then at line 104, the code expects redirectUrls (lowercase):

const redirectURI = client.redirectUrls.find((url) => url === ctx.query.redirect_uri);

For database clients, the property is mapped correctly at line 391:
redirectUrls: (res.redirectUrls ?? "").split(","),

But trustedClients are returned without this mapping, so client.redirectUrls is undefined when the config uses redirectURLs.

Current vs. Expected behavior

Either:

  1. The documentation and TypeScript types should use redirectUrls (lowercase)
  2. Or the getClient function should normalize trustedClients to map redirectURLs → redirectUrls

Workaround

Use redirectUrls (lowercase) instead of redirectURLs in the trustedClients configuration:

trustedClients: [
{
clientId: 'my-app',
// ...
redirectUrls: ['http://localhost:3001/callback'], // lowercase 'urls'
},
],

What version of Better Auth are you using?

1.4.6

System info

{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 25.1.0: Mon Oct 20 19:33:00 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6020",
    "release": "25.1.0",
    "cpuCount": 10,
    "cpuModel": "Apple M2 Pro",
    "totalMemory": "16.00 GB",
    "freeMemory": "0.11 GB"
  },
  "node": {
    "version": "v22.19.0",
    "env": "development"
  },
  "packageManager": {
    "name": "npm",
    "version": "11.6.2"
  },
  "frameworks": [
    {
      "name": "vue",
      "version": "^3.5.25"
    },
    {
      "name": "nuxt",
      "version": "^4.2.1"
    }
  ],
  "databases": [
    {
      "name": "postgres",
      "version": "^3.4.7"
    },
    {
      "name": "drizzle",
      "version": "^0.45.0"
    }
  ],
  "betterAuth": {
    "version": "^1.4.6",
    "config": null
  }
}

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

Documentation, Types

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
});

Additional context

No response

Originally created by @FabianMHz15 on GitHub (Dec 12, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/6724 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Description When configuring trustedClients in the oidcProvider plugin, the documentation shows using redirectURLs (uppercase "URLs"), but the internal code expects redirectUrls (lowercase "urls"). This causes a runtime error when the authorize endpoint tries to validate the redirect URI. Steps to Reproduce 1. Configure oidcProvider with trustedClients: oidcProvider({ loginPage: '/login', trustedClients: [ { clientId: 'my-app', clientSecret: 'secret', name: 'My App', type: 'web', redirectURLs: ['http://localhost:3001/api/auth/oauth2/callback/sso'], // As shown in docs disabled: false, skipConsent: true, metadata: {}, }, ], }) 2. Attempt to authorize via /oauth2/authorize?client_id=my-app&... 3. Error occurs: TypeError: Cannot read properties of undefined (reading 'find') Root Cause In oidc-provider-CDvxiCPp.mjs, the getClient function at line 374-375 returns trusted clients without transformation: const trustedClient = trustedClients.find((client) => client.clientId === clientId); if (trustedClient) return trustedClient; // Returns as-is Then at line 104, the code expects redirectUrls (lowercase): const redirectURI = client.redirectUrls.find((url) => url === ctx.query.redirect_uri); For database clients, the property is mapped correctly at line 391: redirectUrls: (res.redirectUrls ?? "").split(","), But trustedClients are returned without this mapping, so client.redirectUrls is undefined when the config uses redirectURLs. ### Current vs. Expected behavior Either: 1. The documentation and TypeScript types should use redirectUrls (lowercase) 2. Or the getClient function should normalize trustedClients to map redirectURLs → redirectUrls Workaround Use redirectUrls (lowercase) instead of redirectURLs in the trustedClients configuration: trustedClients: [ { clientId: 'my-app', // ... redirectUrls: ['http://localhost:3001/callback'], // lowercase 'urls' }, ], ### What version of Better Auth are you using? 1.4.6 ### System info ```bash { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 25.1.0: Mon Oct 20 19:33:00 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6020", "release": "25.1.0", "cpuCount": 10, "cpuModel": "Apple M2 Pro", "totalMemory": "16.00 GB", "freeMemory": "0.11 GB" }, "node": { "version": "v22.19.0", "env": "development" }, "packageManager": { "name": "npm", "version": "11.6.2" }, "frameworks": [ { "name": "vue", "version": "^3.5.25" }, { "name": "nuxt", "version": "^4.2.1" } ], "databases": [ { "name": "postgres", "version": "^3.4.7" }, { "name": "drizzle", "version": "^0.45.0" } ], "betterAuth": { "version": "^1.4.6", "config": null } } ``` ### Which area(s) are affected? (Select all that apply) Documentation, Types ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, }); ``` ### Additional context _No response_
GiteaMirror added the locked label 2026-04-17 19:12:56 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Dec 12, 2025):

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

This is absolutely suited for GitHub—it's a documentation/types bug that has caused real runtime errors for users. The code and types now expect redirectUrls (lowercase "urls"), but the documentation still shows redirectURLs (uppercase "URLs"), which leads to client.redirectUrls being undefined and breaks the authorize flow. This was fixed in a recent breaking change (PR #5078), so configs and migrations need updating.

Workaround: always use redirectUrls (lowercase) in your trustedClients config. Until the docs are updated, double-check your property names to avoid this error. If you're upgrading from an older version, you may need to run migrations and update any references to the old property name.

Maintainers should prioritize updating the documentation to match the code and types (docs example). Only redirectUrls is supported going forward.

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:3648161167 --> @dosubot[bot] commented on GitHub (Dec 12, 2025): <!-- Greeting --> Hi @FabianMHz15! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> This is absolutely suited for GitHub—it's a documentation/types bug that has caused real runtime errors for users. The code and types now expect `redirectUrls` (lowercase "urls"), but the documentation still shows `redirectURLs` (uppercase "URLs"), which leads to `client.redirectUrls` being undefined and breaks the authorize flow. This was fixed in a recent breaking change ([PR #5078](https://github.com/better-auth/better-auth/pull/5078)), so configs and migrations need updating. Workaround: always use `redirectUrls` (lowercase) in your `trustedClients` config. Until the docs are updated, double-check your property names to avoid this error. If you're upgrading from an older version, you may need to run migrations and update any references to the old property name. Maintainers should prioritize updating the documentation to match the code and types ([docs example](https://github.com/better-auth/better-auth/blob/61ec19e59847f3383d5dba7b1d551c5538429bfb/docs/content/docs/plugins/oidc-provider.mdx#L187-L207)). Only `redirectUrls` is supported going forward. <!-- 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/c9408e50-c4c1-451c-a67e-d0ac90df1d5b?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/c9408e50-c4c1-451c-a67e-d0ac90df1d5b?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/c9408e50-c4c1-451c-a67e-d0ac90df1d5b?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/c9408e50-c4c1-451c-a67e-d0ac90df1d5b?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/c9408e50-c4c1-451c-a67e-d0ac90df1d5b?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/c9408e50-c4c1-451c-a67e-d0ac90df1d5b?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/c9408e50-c4c1-451c-a67e-d0ac90df1d5b?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=This%20is%20absolutely%20suited%20for%20GitHub%E2%80%94it%27s%20a%20documentation/types%20bug%20that%20has%20caused%20real%20runtime%20errors%20for%20users.%20The%20code%20and%20types%20now%20expect%20%60redirectUrls%60%20%28lowercase%20%22urls%22%29%2C%20but%20the%20documentation%20still%20shows%20%60redirectURLs%60%20%28uppercase%20%22URLs%22%29%2C%20which%20leads%20to%20%60client.redirectUrls%60%20being%20undefined%20and%20breaks%20the%20authorize%20flow.%20This%20was%20fixed%20in%20a%20recent%20breaking%20change%20%28%5BPR%20%235078%5D%28https%3A//github.com/better-auth/better-auth/pull/5078%29%29%2C%20so%20configs%20and%20migrations%20need%20updating.%0A%0AWorkaround%3A%20always%20use%20%60redirectUrls%60%20%28lowercase%29%20in%20your%20%60trustedClients%60%20config.%20Until%20the%20docs%20are%20updated%2C%20double-check%20your%20property%20names%20to%20avoid%20this%20error.%20If%20you%27re%20upgrading%20from%20an%20older%20version%2C%20you%20may%20need%20to%20run%20migrations%20and%20update%20any%20references%20to%20the%20old%20property%20name.%0A%0AMaintainers%20should%20prioritize%20updating%20the%20documentation%20to%20match%20the%20code%20and%20types%20%28%5Bdocs%20example%5D%28https%3A//github.com/better-auth/better-auth/blob/61ec19e59847f3383d5dba7b1d551c5538429bfb/docs/content/docs/plugins/oidc-provider.mdx%23L187-L207%29%29.%20Only%20%60redirectUrls%60%20is%20supported%20going%20forward.)&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/6724)
Author
Owner

@GautamBytes commented on GitHub (Dec 13, 2025):

will update the doc

<!-- gh-comment-id:3649541709 --> @GautamBytes commented on GitHub (Dec 13, 2025): will update the doc
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#27924