[PR #6854] [MERGED] fix: respect IP headers in dev/test environments #23824

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6854
Author: @bytaesu
Created: 12/18/2025
Status: Merged
Merged: 12/18/2025
Merged by: @himself65

Base: canaryHead: 2025-12-18/fix/dev-ip-from-headers


📝 Commits (2)

  • 7909921 fix: respect IP headers in dev/test environments
  • 43f75c9 docs: update ip address headers info callout

📊 Changes

2 files changed (+12 additions, -5 deletions)

View changed files

📝 docs/content/docs/reference/security.mdx (+6 -1)
📝 packages/better-auth/src/utils/get-request-ip.ts (+6 -4)

📄 Description

Previously, we always returned a fallback IP in dev/test environments, assuming the IP would be undefined. Now, we first try to get the IP from headers and only return the fallback for dev/test if none is found.

Closes https://github.com/better-auth/better-auth/issues/6838


Summary by cubic

Respect IP headers in development and test by reading x-forwarded-for (and similar) before falling back to localhost. This prevents incorrect localhost IPs behind proxies and aligns behavior with production.

Written for commit 43f75c96c5. 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/6854 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 12/18/2025 **Status:** ✅ Merged **Merged:** 12/18/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `2025-12-18/fix/dev-ip-from-headers` --- ### 📝 Commits (2) - [`7909921`](https://github.com/better-auth/better-auth/commit/7909921b6ff60a15249bf210eaf3c9307a6c3eb4) fix: respect IP headers in dev/test environments - [`43f75c9`](https://github.com/better-auth/better-auth/commit/43f75c96c5e056597d2dfd464d4782882fdf858d) docs: update ip address headers info callout ### 📊 Changes **2 files changed** (+12 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/reference/security.mdx` (+6 -1) 📝 `packages/better-auth/src/utils/get-request-ip.ts` (+6 -4) </details> ### 📄 Description Previously, we always returned a fallback IP in dev/test environments, assuming the IP would be undefined. Now, we first try to get the IP from headers and only return the fallback for dev/test if none is found. Closes https://github.com/better-auth/better-auth/issues/6838 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Respect IP headers in development and test by reading x-forwarded-for (and similar) before falling back to localhost. This prevents incorrect localhost IPs behind proxies and aligns behavior with production. <sup>Written for commit 43f75c96c5e056597d2dfd464d4782882fdf858d. 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 22:00:21 -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#23824