[PR #8649] [MERGED] fix(oauth-provider): handle dynamic baseURL config in init #25019

Closed
opened 2026-04-15 22:41:36 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8649
Author: @himself65
Created: 3/17/2026
Status: Merged
Merged: 3/27/2026
Merged by: @gustavovalverde

Base: mainHead: fix/8559-oauth-provider-baseurl


📝 Commits (2)

  • 939e591 fix(oauth-provider): handle dynamic baseURL config in init (#8559)
  • 052c9ed fix(oauth-provider): narrow dynamic baseURL init fallback

📊 Changes

2 files changed (+59 additions, -1 deletions)

View changed files

📝 packages/oauth-provider/src/oauth.test.ts (+44 -0)
📝 packages/oauth-provider/src/oauth.ts (+15 -1)

📄 Description

Summary

  • The oauth-provider plugin's init() crashes with TypeError: Invalid URL when baseURL uses the object format { allowedHosts, protocol }
  • ctx.baseURL is an empty string during initialization (it's only resolved per-request for dynamic configs)
  • Now gracefully skips init warnings when the URL can't be parsed

Closes #8559

Test plan

  • Configure baseURL with object format { allowedHosts, protocol } alongside oauthProvider plugin
  • Run npx auth generate — should no longer crash with TypeError: Invalid URL

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/8649 **Author:** [@himself65](https://github.com/himself65) **Created:** 3/17/2026 **Status:** ✅ Merged **Merged:** 3/27/2026 **Merged by:** [@gustavovalverde](https://github.com/gustavovalverde) **Base:** `main` ← **Head:** `fix/8559-oauth-provider-baseurl` --- ### 📝 Commits (2) - [`939e591`](https://github.com/better-auth/better-auth/commit/939e5915604130e5e365c06688646e605f2f776b) fix(oauth-provider): handle dynamic baseURL config in init (#8559) - [`052c9ed`](https://github.com/better-auth/better-auth/commit/052c9ed5afd06481610d6debb967e7e4219ff28b) fix(oauth-provider): narrow dynamic baseURL init fallback ### 📊 Changes **2 files changed** (+59 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/oauth-provider/src/oauth.test.ts` (+44 -0) 📝 `packages/oauth-provider/src/oauth.ts` (+15 -1) </details> ### 📄 Description ## Summary - The oauth-provider plugin's `init()` crashes with `TypeError: Invalid URL` when `baseURL` uses the object format `{ allowedHosts, protocol }` - `ctx.baseURL` is an empty string during initialization (it's only resolved per-request for dynamic configs) - Now gracefully skips init warnings when the URL can't be parsed Closes #8559 ## Test plan - Configure `baseURL` with object format `{ allowedHosts, protocol }` alongside `oauthProvider` plugin - Run `npx auth generate` — should no longer crash with `TypeError: Invalid URL` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-15 22:41:36 -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#25019