[GH-ISSUE #8447] BaseURL seems to be empty when using dynamic baseURL #19724

Closed
opened 2026-04-15 19:03:06 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @JE4GLE on GitHub (Mar 6, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/8447

Originally assigned to: @himself65 on GitHub.

To Reproduce

  1. Create Better-Auth Backend
  2. Try to integrated oauth authentication provider
  3. Open the .well-known/openid-configuration endpoint

Current vs. Expected behavior

baseURL is currently empty, while it should be set to {domain}/{basePath}.
This causes OAuth consumers to fail, because the URL is not complete.

What version of Better Auth are you using?

1.5.4

System info

{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 25.3.0: Wed Jan 28 20:54:55 PST 2026; root:xnu-12377.91.3~2/RELEASE_ARM64_T6031",
    "release": "25.3.0",
    "cpuCount": 16,
    "cpuModel": "Apple M3 Max",
    "totalMemory": "64.00 GB",
    "freeMemory": "4.03 GB"
  },
  "node": {
    "version": "v25.2.1",
    "env": "development"
  },
  "packageManager": {
    "name": "npm",
    "version": "11.6.2"
  },
  "frameworks": null,
  "databases": null,
  "betterAuth": {
    "version": "Unknown",
    "config": null,
    "error": "ENOENT: no such file or directory, open 'package.json'"
  }
}

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

Backend, Package

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  baseURL: {
    allowedHosts: [
      'localhost:*',
    ]
    fallback: 'http://localhost:5173',
  }
});

Additional context

BaseURL empty is in this line (and probably other ones):
184cf31e76/packages/oauth-provider/src/metadata.ts (L23-L27)

The baseURL is set here to an empty string:
184cf31e76/packages/better-auth/src/context/create-context.ts (L253-L255)

Because it is set to undefined here:
184cf31e76/packages/better-auth/src/context/create-context.ts (L129-L134)

Originally created by @JE4GLE on GitHub (Mar 6, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/8447 Originally assigned to: @himself65 on GitHub. ### To Reproduce 1. Create Better-Auth Backend 2. Try to integrated oauth authentication provider 3. Open the .well-known/openid-configuration endpoint ### Current vs. Expected behavior `baseURL` is currently empty, while it should be set to `{domain}/{basePath}`. This causes OAuth consumers to fail, because the URL is not complete. ### What version of Better Auth are you using? 1.5.4 ### System info ```json { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 25.3.0: Wed Jan 28 20:54:55 PST 2026; root:xnu-12377.91.3~2/RELEASE_ARM64_T6031", "release": "25.3.0", "cpuCount": 16, "cpuModel": "Apple M3 Max", "totalMemory": "64.00 GB", "freeMemory": "4.03 GB" }, "node": { "version": "v25.2.1", "env": "development" }, "packageManager": { "name": "npm", "version": "11.6.2" }, "frameworks": null, "databases": null, "betterAuth": { "version": "Unknown", "config": null, "error": "ENOENT: no such file or directory, open 'package.json'" } } ``` ### Which area(s) are affected? (Select all that apply) Backend, Package ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ baseURL: { allowedHosts: [ 'localhost:*', ] fallback: 'http://localhost:5173', } }); ``` ### Additional context BaseURL empty is in this line (and probably other ones): https://github.com/better-auth/better-auth/blob/184cf31e765bbacbc3f6180c5455c29803c7d5d9/packages/oauth-provider/src/metadata.ts#L23-L27 The baseURL is set here to an empty string: https://github.com/better-auth/better-auth/blob/184cf31e765bbacbc3f6180c5455c29803c7d5d9/packages/better-auth/src/context/create-context.ts#L253-L255 Because it is set to undefined here: https://github.com/better-auth/better-auth/blob/184cf31e765bbacbc3f6180c5455c29803c7d5d9/packages/better-auth/src/context/create-context.ts#L129-L134
GiteaMirror added the identitybug labels 2026-04-15 19:03:06 -05:00
Author
Owner

@j-fdion commented on GitHub (Mar 12, 2026):

@himself65 Wil your fix work for local dev work? If I have an app running on :3000 and another running :3001, will the latter still be able to use oauth Properly even if the fallback does not the match the app's address?

<!-- gh-comment-id:4046926945 --> @j-fdion commented on GitHub (Mar 12, 2026): @himself65 Wil your fix work for local dev work? If I have an app running on :3000 and another running :3001, will the latter still be able to use oauth Properly even if the fallback does not the match the app's address?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#19724