[PR #6119] [CLOSED] fix(oauth-proxy): handle url correctly when using reverse proxy #23361

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6119
Author: @himself65
Created: 11/20/2025
Status: Closed

Base: canaryHead: himself65/2025/11/19/fix


📝 Commits (6)

  • d81adda fix(oauth-proxy): handle url correctly when using reverse proxy
  • d3baa72 ?
  • 1a6cc5d Update packages/better-auth/src/plugins/oauth-proxy/index.ts
  • f39e7f3 Update packages/better-auth/src/plugins/oauth-proxy/index.ts
  • d27ba83 Update packages/better-auth/src/plugins/oauth-proxy/index.ts
  • 32e3e27 fix: lint

📊 Changes

2 files changed (+109 additions, -4 deletions)

View changed files

📝 packages/better-auth/src/plugins/oauth-proxy/index.ts (+47 -3)
📝 test/unit/oauth/index.spec.ts (+62 -1)

📄 Description

Summary by cubic

Fixes OAuth proxy URL handling behind reverse proxies and ensures absolute redirect URLs. Prevents localhost-based env detection and broken 302 callbacks.

  • Bug Fixes
    • Ignore ctx.request.url when hostname is localhost, 127.0.0.1, or ::1; use vendor/base URL instead.
    • Convert relative Location headers to absolute URLs using the production origin.
    • Add a unit test for BETTER_AUTH_URL proxy scenarios.

Written for commit 32e3e2729d. 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/6119 **Author:** [@himself65](https://github.com/himself65) **Created:** 11/20/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `himself65/2025/11/19/fix` --- ### 📝 Commits (6) - [`d81adda`](https://github.com/better-auth/better-auth/commit/d81adda0bab82b5f53283160b7e4cc1580d1dc5c) fix(oauth-proxy): handle url correctly when using reverse proxy - [`d3baa72`](https://github.com/better-auth/better-auth/commit/d3baa72d6a3e399429f26676c612378e5b3e131b) ? - [`1a6cc5d`](https://github.com/better-auth/better-auth/commit/1a6cc5dbf200e1891a70a5ae5e83f389eeaf0b30) Update packages/better-auth/src/plugins/oauth-proxy/index.ts - [`f39e7f3`](https://github.com/better-auth/better-auth/commit/f39e7f3af782ab1f2ca1fb280b823b2f99e836ee) Update packages/better-auth/src/plugins/oauth-proxy/index.ts - [`d27ba83`](https://github.com/better-auth/better-auth/commit/d27ba83261adee435e4cc150b508bedae57430d2) Update packages/better-auth/src/plugins/oauth-proxy/index.ts - [`32e3e27`](https://github.com/better-auth/better-auth/commit/32e3e2729d8c198362fd3fbf8c02667df533a5b9) fix: lint ### 📊 Changes **2 files changed** (+109 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/oauth-proxy/index.ts` (+47 -3) 📝 `test/unit/oauth/index.spec.ts` (+62 -1) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Fixes OAuth proxy URL handling behind reverse proxies and ensures absolute redirect URLs. Prevents localhost-based env detection and broken 302 callbacks. - **Bug Fixes** - Ignore ctx.request.url when hostname is localhost, 127.0.0.1, or ::1; use vendor/base URL instead. - Convert relative Location headers to absolute URLs using the production origin. - Add a unit test for BETTER_AUTH_URL proxy scenarios. <sup>Written for commit 32e3e2729d8c198362fd3fbf8c02667df533a5b9. 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-04-15 21:39: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#23361