Skip to content

Commit 0f3a810

Browse files
nanotaboadaclaude
andcommitted
fix(middleware): exempt health check from rate limiter via DisableRateLimiting() (#451)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2774c66 commit 0f3a810

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ This project uses famous football stadiums (A-Z) that hosted FIFA World Cup matc
5454

5555
### Changed
5656

57+
- Call `.DisableRateLimiting()` on `MapHealthChecks("/health")` to enforce the exemption from the global rate limiter at the endpoint level, ensuring health check probes are never throttled (#451)
5758
- Move `UseCors()` before `MapControllers()` in `Program.cs` to follow the standard ASP.NET Core middleware pipeline order; add an `Infrastructure` service registration section separating cross-cutting concerns (health checks, CORS, rate limiting, Swagger) from the `Controllers` section; add descriptive phrases to top-level section banners; add inline comments explaining the purpose and ordering rationale of each middleware; document the dev-only CORS policy intent in both `Program.cs` and `ServiceCollectionExtensions.AddCorsDefaultPolicy` (#451)
5859
- Replace pre-seeded `storage/players-sqlite3.db` binary blob with EF Core `MigrateAsync()` at startup: schema and seed data are now applied automatically before the first request is served; `STORAGE_PATH` env var controls the database file path (Docker volume path in production, `AppContext.BaseDirectory/storage/` locally); the committed database file, `Dockerfile` db copy step, and `scripts/run-migrations-and-copy-database.sh` have been removed (#459)
5960
- Recreate EF Core migrations using `HasData()` in `OnModelCreating`: three self-contained migrations (`InitialCreate` DDL, `SeedStarting11` DML, `SeedSubstitutes` DML) generated by EF Core with literal `InsertData` values — no migration calls application methods; `NormalizePlayerDataset` patch migration eliminated by folding corrections into seed data from the start (#459)

src/Dotnet.Samples.AspNetCore.WebApi/Program.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,10 @@
8989
// Redirects all plain HTTP requests to HTTPS, enforcing transport security.
9090
app.UseHttpsRedirection();
9191

92-
// Intentionally registered before UseRateLimiter so that health check probes
93-
// always succeed regardless of rate-limiting thresholds, allowing monitoring
94-
// and orchestration systems to assess liveness and readiness without being
95-
// throttled.
96-
app.MapHealthChecks("/health");
92+
// DisableRateLimiting() exempts the health check endpoint from the global rate
93+
// limiter so that monitoring and orchestration systems can always assess
94+
// liveness and readiness without being throttled.
95+
app.MapHealthChecks("/health").DisableRateLimiting();
9796

9897
// Enforces the fixed-window rate limiting policy defined during service
9998
// registration, returning 429 Too Many Requests when the limit is exceeded.

0 commit comments

Comments
 (0)