[PR #6232] [MERGED] fix: set Location header on redirected responses #23435

Closed
opened 2026-04-15 21:43:11 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6232
Author: @GautamBytes
Created: 11/23/2025
Status: Merged
Merged: 1/8/2026
Merged by: @ping-maxwell

Base: canaryHead: fix/location-header-redirects


📝 Commits (3)

  • ae1f666 add Location header to redirect responses
  • b002b48 rebase and lint
  • cbdae90 Merge branch 'canary' into fix/location-header-redirects

📊 Changes

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

View changed files

📝 packages/better-auth/src/api/routes/account.ts (+4 -0)
📝 packages/better-auth/src/api/routes/sign-in.ts (+9 -0)

📄 Description

This PR addresses issue #6219 by adding the standard Location header to API responses that include a redirect URL in their JSON body. This improves interoperability with server-side frameworks (like SvelteKit, Remix, and Next.js) that rely on inspecting headers for navigation logic.

Changes:

Modified packages/better-auth/src/api/routes/sign-in.ts:

  • Added Location header to signInSocial when disableRedirect is false.
  • Added Location header to signInEmail when callbackURL is present.

Modified packages/better-auth/src/api/routes/account.ts:

  • Added Location header to linkSocialAccount when disableRedirect is false.

Summary by cubic

Add the standard Location header to auth API responses that include a redirect URL, improving compatibility with frameworks that read headers (e.g., SvelteKit, Remix, Next.js). This aligns headers with the JSON body so clients can reliably navigate.

  • Bug Fixes
    • signInSocial: set Location when disableRedirect is false.
    • signInEmail: set Location when callbackURL is present.
    • linkSocialAccount: set Location when disableRedirect is false.

Written for commit cbdae90b91. 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/6232 **Author:** [@GautamBytes](https://github.com/GautamBytes) **Created:** 11/23/2025 **Status:** ✅ Merged **Merged:** 1/8/2026 **Merged by:** [@ping-maxwell](https://github.com/ping-maxwell) **Base:** `canary` ← **Head:** `fix/location-header-redirects` --- ### 📝 Commits (3) - [`ae1f666`](https://github.com/better-auth/better-auth/commit/ae1f666fee380208dfb99d0647fbd487acfc8c81) add Location header to redirect responses - [`b002b48`](https://github.com/better-auth/better-auth/commit/b002b48ea85e86e8c16f321aed2825426672478e) rebase and lint - [`cbdae90`](https://github.com/better-auth/better-auth/commit/cbdae90b915687ed53b76d57e4865a6e37cf2238) Merge branch 'canary' into fix/location-header-redirects ### 📊 Changes **2 files changed** (+13 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/routes/account.ts` (+4 -0) 📝 `packages/better-auth/src/api/routes/sign-in.ts` (+9 -0) </details> ### 📄 Description This PR addresses issue #6219 by adding the standard Location header to API responses that include a redirect URL in their JSON body. This improves interoperability with server-side frameworks (like SvelteKit, Remix, and Next.js) that rely on inspecting headers for navigation logic. **Changes**: Modified packages/better-auth/src/api/routes/sign-in.ts: - Added Location header to signInSocial when disableRedirect is false. - Added Location header to signInEmail when callbackURL is present. Modified packages/better-auth/src/api/routes/account.ts: - Added Location header to linkSocialAccount when disableRedirect is false. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Add the standard Location header to auth API responses that include a redirect URL, improving compatibility with frameworks that read headers (e.g., SvelteKit, Remix, Next.js). This aligns headers with the JSON body so clients can reliably navigate. - **Bug Fixes** - signInSocial: set Location when disableRedirect is false. - signInEmail: set Location when callbackURL is present. - linkSocialAccount: set Location when disableRedirect is false. <sup>Written for commit cbdae90b915687ed53b76d57e4865a6e37cf2238. 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-04-15 21:43:11 -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#23435