[PR #8644] fix(oauth-provider): handle dynamic baseURL config in init #16360

Closed
opened 2026-04-13 10:30:10 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/8644

State: closed
Merged: No


Summary

  • The oauth-provider plugin's init() function crashes with TypeError: Invalid URL when baseURL uses the object format { allowedHosts, protocol } instead of a string, because ctx.baseURL is an empty string during initialization (it's only resolved per-request).
  • Wraps new URL(issuer) in a try/catch so that init gracefully skips warnings when the URL can't be parsed.

Fixes #8559

Test plan

  • Verify that configuring baseURL as an object (e.g., { allowedHosts: ["example.com"], protocol: "https" }) no longer crashes the oauth-provider plugin during initialization.
  • Verify that string-based baseURL configurations continue to work as before (init warnings are still shown).
**Original Pull Request:** https://github.com/better-auth/better-auth/pull/8644 **State:** closed **Merged:** No --- ## Summary - The oauth-provider plugin's `init()` function crashes with `TypeError: Invalid URL` when `baseURL` uses the object format `{ allowedHosts, protocol }` instead of a string, because `ctx.baseURL` is an empty string during initialization (it's only resolved per-request). - Wraps `new URL(issuer)` in a try/catch so that init gracefully skips warnings when the URL can't be parsed. Fixes #8559 ## Test plan - Verify that configuring `baseURL` as an object (e.g., `{ allowedHosts: ["example.com"], protocol: "https" }`) no longer crashes the oauth-provider plugin during initialization. - Verify that string-based `baseURL` configurations continue to work as before (init warnings are still shown).
GiteaMirror added the pull-request label 2026-04-13 10:30:10 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#16360