Skip to content

Commit

Permalink
fix : anonymous health checks
Browse files Browse the repository at this point in the history
  • Loading branch information
iammukeshm authored Aug 21, 2024
1 parent dd43361 commit ed6585b
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/aspire/service-defaults/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,20 +143,15 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app)
if (context.Request.Path != "/metrics") return false;
return true;
});

// All health checks must pass for app to be considered ready to accept traffic after starting
app.MapHealthChecks("/health").AllowAnonymous();

// Adding health checks endpoints to applications in non-development environments has security implications.
// See https://aka.ms/dotnet/aspire/healthchecks for details before enabling these endpoints in non-development environments.
if (app.Environment.IsDevelopment())
// Only health checks tagged with the "live" tag must pass for app to be considered alive
app.MapHealthChecks("/alive", new HealthCheckOptions
{
// All health checks must pass for app to be considered ready to accept traffic after starting
app.MapHealthChecks("/health").AllowAnonymous();

// Only health checks tagged with the "live" tag must pass for app to be considered alive
app.MapHealthChecks("/alive", new HealthCheckOptions
{
Predicate = r => r.Tags.Contains("live")
}).AllowAnonymous();
}
Predicate = r => r.Tags.Contains("live")
}).AllowAnonymous();

return app;
}
Expand Down

0 comments on commit ed6585b

Please sign in to comment.