[PR #5436] [MERGED] test: rate limiting in dev/test environment #31608

Closed
opened 2026-04-17 22:30:10 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5436
Author: @bytaesu
Created: 10/20/2025
Status: Merged
Merged: 10/20/2025
Merged by: @himself65

Base: canaryHead: 2025-10-21/test/localhost-rate-limit


📝 Commits (2)

  • 5eafb15 refactor: cleanup test and dev environment handling
  • 97161b2 test: add test cases for dev/test environment

📊 Changes

2 files changed (+108 additions, -6 deletions)

View changed files

📝 packages/better-auth/src/api/rate-limiter/rate-limiter.test.ts (+103 -1)
📝 packages/better-auth/src/utils/get-request-ip.ts (+5 -5)

📄 Description

This PR refactors the dev/test environment code in the rate limiter and clearly adds the related test cases.

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


Summary by cubic

Make rate limiting consistent in development and test by using a fixed localhost IP and adding targeted tests. Requests in dev/test now resolve to 127.0.0.1, and the limiter correctly enforces 429s and stores keys as 127.0.0.1 + path.

  • Refactors
    • Unified dev/test IP handling in get-request-ip via a LOCALHOST_IP constant.
    • Simplified environment checks to a single isTest || isDevelopment condition.

🔄 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/5436 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 10/20/2025 **Status:** ✅ Merged **Merged:** 10/20/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `2025-10-21/test/localhost-rate-limit` --- ### 📝 Commits (2) - [`5eafb15`](https://github.com/better-auth/better-auth/commit/5eafb15fd9065174b4487696ce7773825a483862) refactor: cleanup test and dev environment handling - [`97161b2`](https://github.com/better-auth/better-auth/commit/97161b275020e493e9134892572db5104ae64cc5) test: add test cases for dev/test environment ### 📊 Changes **2 files changed** (+108 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/rate-limiter/rate-limiter.test.ts` (+103 -1) 📝 `packages/better-auth/src/utils/get-request-ip.ts` (+5 -5) </details> ### 📄 Description This PR refactors the dev/test environment code in the rate limiter and clearly adds the related test cases. Closes https://github.com/better-auth/better-auth/issues/2633 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Make rate limiting consistent in development and test by using a fixed localhost IP and adding targeted tests. Requests in dev/test now resolve to 127.0.0.1, and the limiter correctly enforces 429s and stores keys as 127.0.0.1 + path. - **Refactors** - Unified dev/test IP handling in get-request-ip via a LOCALHOST_IP constant. - Simplified environment checks to a single isTest || isDevelopment condition. <!-- 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-17 22:30:10 -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#31608