[PR #3770] [MERGED] fix: magic link URL construction #4995

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/3770
Author: @Kinfe123
Created: 8/3/2025
Status: Merged
Merged: 8/6/2025
Merged by: @Bekacru

Base: canaryHead: fix/magic-link-baseurl-conflict


📝 Commits (5)

📊 Changes

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

View changed files

📝 packages/better-auth/src/plugins/magic-link/index.ts (+4 -1)
📝 packages/better-auth/src/plugins/magic-link/magic-link.test.ts (+3 -1)

📄 Description

The issue occurs when the baseURL has a root pathname ("/"), causing double slashes in URL construction that result in malformed magic link URLs. The fix treats root pathnames as empty strings, preventing the double slash issue and ensuring proper URL construction with the correct host and port information.

closes #3759


🔄 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/3770 **Author:** [@Kinfe123](https://github.com/Kinfe123) **Created:** 8/3/2025 **Status:** ✅ Merged **Merged:** 8/6/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/magic-link-baseurl-conflict` --- ### 📝 Commits (5) - [`856e583`](https://github.com/better-auth/better-auth/commit/856e5833f20224a4ab6b154bdd084421bd9ed8a7) magic link pathname issue - [`3e9f4df`](https://github.com/better-auth/better-auth/commit/3e9f4df405bb2eff52e18981fce1bcd360957e53) lint - [`ca6a0ee`](https://github.com/better-auth/better-auth/commit/ca6a0ee9dc64826d66136c6663acf52b50c7e143) changesets - [`1ba685e`](https://github.com/better-auth/better-auth/commit/1ba685e9c4a5488e16830825e5bacc3418861106) remove changesets - [`5dd7000`](https://github.com/better-auth/better-auth/commit/5dd70007fc9def6a444276a9c42cdcdafaac8394) respect basePath if baseUrl has no pathname ### 📊 Changes **2 files changed** (+7 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/magic-link/index.ts` (+4 -1) 📝 `packages/better-auth/src/plugins/magic-link/magic-link.test.ts` (+3 -1) </details> ### 📄 Description The issue occurs when the baseURL has a root pathname ("/"), causing double slashes in URL construction that result in malformed magic link URLs. The fix treats root pathnames as empty strings, preventing the double slash issue and ensuring proper URL construction with the correct host and port information. closes #3759 --- <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:06:42 -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#4995