Skip to content

Commit 11912ee

Browse files
authored
Use POST request to check if the API is available (#1853)
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
1 parent 753dc15 commit 11912ee

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/Elastic.Documentation.Site/Assets/web-components/SearchOrAskAi/SearchOrAskAiButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ export const SearchOrAskAiButton = () => {
3333
const { data: isApiAvailable } = useQuery({
3434
queryKey: ['api-health'],
3535
queryFn: async () => {
36-
const response = await fetch('/docs/_api/v1/')
36+
const response = await fetch('/docs/_api/v1/', { method: 'POST' })
3737
return response.ok
3838
},
39-
staleTime: 5 * 60 * 1000, // 5 minutes
39+
staleTime: 60 * 60 * 1000, // 60 minutes
4040
retry: false,
4141
})
4242

src/api/Elastic.Documentation.Api.Infrastructure/MappingsExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public static class MappingsExtension
1616
public static void MapElasticDocsApiEndpoints(this IEndpointRouteBuilder group)
1717
{
1818
_ = group.MapGet("/", () => Results.Empty);
19+
_ = group.MapPost("/", () => Results.Empty);
1920
MapAskAiEndpoint(group);
2021
MapSearchEndpoint(group);
2122
}

0 commit comments

Comments
 (0)