From c03c12cb7e8170cda87ba5aa01bc4eb13bc3d802 Mon Sep 17 00:00:00 2001 From: Jan Calanog Date: Mon, 8 Sep 2025 15:23:43 +0200 Subject: [PATCH] Use POST request to check if the API is available GET requests are cached on the edge. which means, once a user with VPN gets a 200 OK, all users in the region get a 200 OK, which is not the intended behaviour POST requests are not cached --- .../web-components/SearchOrAskAi/SearchOrAskAiButton.tsx | 4 ++-- .../MappingsExtensions.cs | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Elastic.Documentation.Site/Assets/web-components/SearchOrAskAi/SearchOrAskAiButton.tsx b/src/Elastic.Documentation.Site/Assets/web-components/SearchOrAskAi/SearchOrAskAiButton.tsx index 18f914b47..ff649de4a 100644 --- a/src/Elastic.Documentation.Site/Assets/web-components/SearchOrAskAi/SearchOrAskAiButton.tsx +++ b/src/Elastic.Documentation.Site/Assets/web-components/SearchOrAskAi/SearchOrAskAiButton.tsx @@ -33,10 +33,10 @@ export const SearchOrAskAiButton = () => { const { data: isApiAvailable } = useQuery({ queryKey: ['api-health'], queryFn: async () => { - const response = await fetch('/docs/_api/v1/') + const response = await fetch('/docs/_api/v1/', { method: 'POST' }) return response.ok }, - staleTime: 5 * 60 * 1000, // 5 minutes + staleTime: 60 * 60 * 1000, // 60 minutes retry: false, }) diff --git a/src/api/Elastic.Documentation.Api.Infrastructure/MappingsExtensions.cs b/src/api/Elastic.Documentation.Api.Infrastructure/MappingsExtensions.cs index 0e49d80c7..80f3c2701 100644 --- a/src/api/Elastic.Documentation.Api.Infrastructure/MappingsExtensions.cs +++ b/src/api/Elastic.Documentation.Api.Infrastructure/MappingsExtensions.cs @@ -16,6 +16,7 @@ public static class MappingsExtension public static void MapElasticDocsApiEndpoints(this IEndpointRouteBuilder group) { _ = group.MapGet("/", () => Results.Empty); + _ = group.MapPost("/", () => Results.Empty); MapAskAiEndpoint(group); MapSearchEndpoint(group); }