[PR #8364] [CLOSED] fix(sso): allow bare domains for SSO domain verification #7925

Closed
opened 2026-03-13 13:53:26 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8364
Author: @GautamBytes
Created: 3/4/2026
Status: Closed

Base: canaryHead: fix/sso-domain-parsing


📝 Commits (1)

  • 4f29c60 fix(sso): support bare domains in domain verification

📊 Changes

2 files changed (+50 additions, -2 deletions)

View changed files

📝 packages/sso/src/domain-verification.test.ts (+39 -1)
📝 packages/sso/src/routes/domain-verification.ts (+11 -1)

📄 Description

Resolves #8361

Description

The SSO requestDomainVerification and verifyDomain endpoints previously threw an ERR_INVALID_URL if the SSO provider was registered with a bare domain (e.g., github.com) instead of a full URL (e.g., https://github.com). This mismatch occurred because the native URL constructor requires a protocol scheme.

This PR introduces an internal normalization helper (getHostnameFromDomainInput) that prepends a secure scheme (https://) to bare domains before parsing them.

Changes

  • Replaced direct new URL() calls with a normalization function in packages/sso/src/routes/domain-verification.ts.
  • Updated test fixtures to use a bare domain (hello.com) as the default to prevent future regressions.
  • Added a dedicated test case to ensure full URLs (http://hello.com:8081) continue to be parsed correctly, preserving backward compatibility.

Summary by cubic

Fix SSO domain verification to accept bare domains (e.g., github.com) without throwing ERR_INVALID_URL. We normalize inputs by adding https when missing and parse the hostname, keeping full URLs supported.

  • Bug Fixes
    • Added getHostnameFromDomainInput to normalize domain inputs and safely extract the hostname.
    • Updated tests to default to a bare domain and added a case for full URLs to prevent regressions.

Written for commit 4f29c609bd. Summary will update 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/8364 **Author:** [@GautamBytes](https://github.com/GautamBytes) **Created:** 3/4/2026 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `fix/sso-domain-parsing` --- ### 📝 Commits (1) - [`4f29c60`](https://github.com/better-auth/better-auth/commit/4f29c609bd6274f2ae6d7d7e5a07363e9f2dc875) fix(sso): support bare domains in domain verification ### 📊 Changes **2 files changed** (+50 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/sso/src/domain-verification.test.ts` (+39 -1) 📝 `packages/sso/src/routes/domain-verification.ts` (+11 -1) </details> ### 📄 Description Resolves #8361 ### Description The SSO `requestDomainVerification` and `verifyDomain` endpoints previously threw an `ERR_INVALID_URL` if the SSO provider was registered with a bare domain (e.g., `github.com`) instead of a full URL (e.g., `https://github.com`). This mismatch occurred because the native `URL` constructor requires a protocol scheme. This PR introduces an internal normalization helper (`getHostnameFromDomainInput`) that prepends a secure scheme (`https://`) to bare domains before parsing them. ### Changes - Replaced direct `new URL()` calls with a normalization function in `packages/sso/src/routes/domain-verification.ts`. - Updated test fixtures to use a bare domain (`hello.com`) as the default to prevent future regressions. - Added a dedicated test case to ensure full URLs (`http://hello.com:8081`) continue to be parsed correctly, preserving backward compatibility. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fix SSO domain verification to accept bare domains (e.g., github.com) without throwing ERR_INVALID_URL. We normalize inputs by adding https when missing and parse the hostname, keeping full URLs supported. - **Bug Fixes** - Added getHostnameFromDomainInput to normalize domain inputs and safely extract the hostname. - Updated tests to default to a bare domain and added a case for full URLs to prevent regressions. <sup>Written for commit 4f29c609bd6274f2ae6d7d7e5a07363e9f2dc875. Summary will update 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 13:53:26 -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#7925