[PR #7893] [CLOSED] fix(client): allow custom baseURL protocols #15862

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7893
Author: @jayy-77
Created: 2/10/2026
Status: Closed

Base: canaryHead: fix/allow-custom-baseurl-protocols-7149


📝 Commits (1)

  • 4e0c9bb fix(client): allow custom baseURL protocols

📊 Changes

5 files changed (+92 additions, -10 deletions)

View changed files

📝 packages/better-auth/src/client/client.test.ts (+23 -0)
📝 packages/better-auth/src/client/config.ts (+9 -1)
📝 packages/better-auth/src/utils/url.test.ts (+20 -0)
📝 packages/better-auth/src/utils/url.ts (+28 -9)
📝 packages/core/src/types/plugin-client.ts (+12 -0)

📄 Description

Problem

Better Auth client rejects non-http(s) baseURL values (e.g. electronapp://api) due to strict protocol validation in getBaseURL(). This blocks Electron/Tauri-style setups that proxy requests through a custom protocol.

Changes

  • Add allowCustomBaseURLProtocol?: boolean to BetterAuthClientOptions.
  • Extend getBaseURL() with an explicit protocol policy (default remains strict http/https).
  • When allowCustomBaseURLProtocol is enabled, client config resolves baseURL with protocolPolicy=any.
  • Add regression tests covering default rejection + opt-in allowance.

Why this approach

  • Keeps default behavior strict for web/server usage.
  • Allows desktop runtimes to opt in explicitly, avoiding accidental loosening.

Test plan

  • pnpm build
  • pnpm -F better-auth test (requires Postgres running for the oauth-proxy postgres suite)

Fixes #7149


🔄 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/7893 **Author:** [@jayy-77](https://github.com/jayy-77) **Created:** 2/10/2026 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `fix/allow-custom-baseurl-protocols-7149` --- ### 📝 Commits (1) - [`4e0c9bb`](https://github.com/better-auth/better-auth/commit/4e0c9bb94b576fdcad22f9b6719ff3019ab7e87a) fix(client): allow custom baseURL protocols ### 📊 Changes **5 files changed** (+92 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/client/client.test.ts` (+23 -0) 📝 `packages/better-auth/src/client/config.ts` (+9 -1) 📝 `packages/better-auth/src/utils/url.test.ts` (+20 -0) 📝 `packages/better-auth/src/utils/url.ts` (+28 -9) 📝 `packages/core/src/types/plugin-client.ts` (+12 -0) </details> ### 📄 Description ## Problem Better Auth client rejects non-http(s) `baseURL` values (e.g. `electronapp://api`) due to strict protocol validation in `getBaseURL()`. This blocks Electron/Tauri-style setups that proxy requests through a custom protocol. ## Changes - Add `allowCustomBaseURLProtocol?: boolean` to `BetterAuthClientOptions`. - Extend `getBaseURL()` with an explicit protocol policy (default remains strict http/https). - When `allowCustomBaseURLProtocol` is enabled, client config resolves `baseURL` with protocolPolicy=`any`. - Add regression tests covering default rejection + opt-in allowance. ## Why this approach - Keeps **default** behavior strict for web/server usage. - Allows desktop runtimes to opt in explicitly, avoiding accidental loosening. ## Test plan - `pnpm build` - `pnpm -F better-auth test` (requires Postgres running for the oauth-proxy postgres suite) Fixes #7149 --- <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-13 10:16:15 -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#15862