[PR #5902] [MERGED] fix: validate baseURL protocol and improve error messages #6308

Closed
opened 2026-03-13 12:54:17 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5902
Author: @dmmulroy
Created: 11/11/2025
Status: Merged
Merged: 11/11/2025
Merged by: @himself65

Base: canaryHead: canary


📝 Commits (3)

  • 8ab5d37 Add baseUrl protocol checks + error to improve DX
  • 4563738 Update packages/better-auth/src/init.test.ts
  • 310db34 pr feedback

📊 Changes

2 files changed (+37 additions, -0 deletions)

View changed files

📝 packages/better-auth/src/init.test.ts (+16 -0)
📝 packages/better-auth/src/utils/url.ts (+21 -0)

📄 Description

Using localhost:3000 (without protocol) as baseURL in env vars caused unclear errors during schema generation. This adds protocol validation with actionable error messages to improve DX.


Summary by cubic

Validate baseURL protocol and show clear errors when it's missing or unsupported. This prevents misconfigurations and improves DX by only allowing http/https.

  • Bug Fixes
    • Enforce http/https protocols via URL parsing in withPath().
    • Throw BetterAuthError with actionable messages for invalid or malformed base URLs.
    • Add tests for missing protocol and ws:// URLs.

Written for commit 310db3400b. Summary will update automatically on new commits.


🔄 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/5902 **Author:** [@dmmulroy](https://github.com/dmmulroy) **Created:** 11/11/2025 **Status:** ✅ Merged **Merged:** 11/11/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `canary` --- ### 📝 Commits (3) - [`8ab5d37`](https://github.com/better-auth/better-auth/commit/8ab5d372607e6c72fbc5a343f920119345e6911b) Add baseUrl protocol checks + error to improve DX - [`4563738`](https://github.com/better-auth/better-auth/commit/456373853d4500c3bd3f900b8ab9d597e381aa2c) Update packages/better-auth/src/init.test.ts - [`310db34`](https://github.com/better-auth/better-auth/commit/310db3400bcd67ced64de588bd4d800a7ca95d78) pr feedback ### 📊 Changes **2 files changed** (+37 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/init.test.ts` (+16 -0) 📝 `packages/better-auth/src/utils/url.ts` (+21 -0) </details> ### 📄 Description Using localhost:3000 (without protocol) as baseURL in env vars caused unclear errors during schema generation. This adds protocol validation with actionable error messages to improve DX. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Validate baseURL protocol and show clear errors when it's missing or unsupported. This prevents misconfigurations and improves DX by only allowing http/https. - **Bug Fixes** - Enforce http/https protocols via URL parsing in withPath(). - Throw BetterAuthError with actionable messages for invalid or malformed base URLs. - Add tests for missing protocol and ws:// URLs. <sup>Written for commit 310db3400bcd67ced64de588bd4d800a7ca95d78. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <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-03-13 12:54:17 -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#6308