diff --git a/Frontend/CO.CDP.OrganisationApp/AuthenticatedSessionAwareMiddleware.cs b/Frontend/CO.CDP.OrganisationApp/AuthenticatedSessionAwareMiddleware.cs index d101366f0..fa4796775 100644 --- a/Frontend/CO.CDP.OrganisationApp/AuthenticatedSessionAwareMiddleware.cs +++ b/Frontend/CO.CDP.OrganisationApp/AuthenticatedSessionAwareMiddleware.cs @@ -7,24 +7,27 @@ public class AuthenticatedSessionAwareMiddleware(RequestDelegate next, ISession { public async Task Invoke(HttpContext context) { - var endpoint = context.GetEndpoint(); - - if (endpoint != null) + if (context.Request.Path != "/health") { - if (endpoint.Metadata.GetMetadata() is null) + var endpoint = context.GetEndpoint(); + + if (endpoint != null) { - if (context.User.Identity?.IsAuthenticated == false) + if (endpoint.Metadata.GetMetadata() is null) { - context.Response.Redirect("/"); - return; - } + if (context.User.Identity?.IsAuthenticated == false) + { + context.Response.Redirect("/"); + return; + } - var details = session.Get(Session.UserDetailsKey); + var details = session.Get(Session.UserDetailsKey); - if (details == null) - { - context.Response.Redirect("/"); - return; + if (details == null) + { + context.Response.Redirect("/"); + return; + } } } } diff --git a/Frontend/CO.CDP.OrganisationApp/Program.cs b/Frontend/CO.CDP.OrganisationApp/Program.cs index 1f0f3d3f7..170ce5df6 100644 --- a/Frontend/CO.CDP.OrganisationApp/Program.cs +++ b/Frontend/CO.CDP.OrganisationApp/Program.cs @@ -179,7 +179,7 @@ app.UseHsts(); } -app.MapHealthChecks("/health"); +app.MapHealthChecks("/health").AllowAnonymous(); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting();