diff --git a/TramsDataApi/Middleware/ApiKeyMiddleware.cs b/TramsDataApi/Middleware/ApiKeyMiddleware.cs index d0f0778d5..04364916c 100644 --- a/TramsDataApi/Middleware/ApiKeyMiddleware.cs +++ b/TramsDataApi/Middleware/ApiKeyMiddleware.cs @@ -20,6 +20,12 @@ public ApiKeyMiddleware(RequestDelegate next, ILogger logger) } public async Task InvokeAsync(HttpContext context, IUseCase apiKeyService) { + // Bypass API Key requirement for health check route + if (context.Request.Path == "/HealthCheck") { + await _next(context); + return; + } + if (!context.Request.Headers.TryGetValue(APIKEYNAME, out var extractedApiKey)) { context.Response.StatusCode = 401; @@ -43,4 +49,4 @@ public async Task InvokeAsync(HttpContext context, IUseCase api } } } -} \ No newline at end of file +}