[PR #2621] [CLOSED] fix: uri-encode callbackURL for magic link to allow for query params #4405

Closed
opened 2026-03-13 11:44:46 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/2621
Author: @philipp-lampert
Created: 5/11/2025
Status: Closed

Base: mainHead: fix/magic-link-callback-url


📝 Commits (1)

  • 6045b6f fix: uri-encode callbackURL for magic link to allow for query params

📊 Changes

1 file changed (+7 additions, -4 deletions)

View changed files

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

📄 Description

Fixes an issue preventing magic link authentication from correctly redirecting to callbackURLs with query parameters (e.g., /dashboard?view=reports&filter=last_month).

The fix involves:

  1. Properly URI-encoding the callbackURL when the magic link is generated.
  2. Correctly URI-decoding this callbackURL during the verification step before the redirect and for originCheck validation.

This is crucial for restoring post-login redirection to specific states.

Closes #2592


🔄 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/2621 **Author:** [@philipp-lampert](https://github.com/philipp-lampert) **Created:** 5/11/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/magic-link-callback-url` --- ### 📝 Commits (1) - [`6045b6f`](https://github.com/better-auth/better-auth/commit/6045b6ff908b141d79d22d558e7a70cf95eb1f80) fix: uri-encode callbackURL for magic link to allow for query params ### 📊 Changes **1 file changed** (+7 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/magic-link/index.ts` (+7 -4) </details> ### 📄 Description Fixes an issue preventing magic link authentication from correctly redirecting to `callbackURL`s with query parameters (e.g., `/dashboard?view=reports&filter=last_month`). The fix involves: 1. Properly URI-encoding the `callbackURL` when the magic link is generated. 2. Correctly URI-decoding this `callbackURL` during the verification step before the redirect and for `originCheck` validation. This is crucial for restoring post-login redirection to specific states. Closes #2592 --- <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 11:44:46 -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#4405