Skip to content

Commit 7658224

Browse files
committed
feat: Enable health check endpoints unconditionally across all environments and update related comments.
1 parent c14599a commit 7658224

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

src/BookStore.ServiceDefaults/Extensions.cs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,19 +130,20 @@ public static TBuilder AddDefaultHealthChecks<TBuilder>(this TBuilder builder) w
130130

131131
public static WebApplication MapDefaultEndpoints(this WebApplication app)
132132
{
133-
// Adding health checks endpoints to applications in non-development environments has security implications.
134-
// See https://aka.ms/dotnet/aspire/healthchecks for details before enabling these endpoints in non-development environments.
135-
if (app.Environment.IsDevelopment())
136-
{
137-
// All health checks must pass for app to be considered ready to accept traffic after starting
138-
_ = app.MapHealthChecks(HealthEndpointPath);
133+
// Health check endpoints are essential for production (load balancers, orchestrators, monitoring).
134+
// These endpoints return minimal information (200 OK or 503 Service Unavailable).
135+
// For production deployments, use network-level protection (firewall rules) to restrict access
136+
// to trusted sources: load balancers, Kubernetes, monitoring systems, internal networks.
137+
// See https://aka.ms/dotnet/aspire/healthchecks for more details.
139138

140-
// Only health checks tagged with the "live" tag must pass for app to be considered alive
141-
_ = app.MapHealthChecks(AlivenessEndpointPath, new HealthCheckOptions
142-
{
143-
Predicate = r => r.Tags.Contains("live")
144-
});
145-
}
139+
// Readiness probe: All health checks must pass for app to be ready to accept traffic
140+
_ = app.MapHealthChecks(HealthEndpointPath);
141+
142+
// Liveness probe: Only "live" tagged checks must pass for app to be considered alive
143+
_ = app.MapHealthChecks(AlivenessEndpointPath, new HealthCheckOptions
144+
{
145+
Predicate = r => r.Tags.Contains("live")
146+
});
146147

147148
return app;
148149
}

0 commit comments

Comments
 (0)