Skip to content

Commit b84fa54

Browse files
authored
Merge branch 'main' into update-applies-to-docs
2 parents 1eb0822 + 4fd3a61 commit b84fa54

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
EuiLoadingSpinner,
1414
} from '@elastic/eui'
1515
import { css } from '@emotion/react'
16+
import { useQuery } from '@tanstack/react-query'
1617
import * as React from 'react'
1718
import { useEffect, Suspense, lazy } from 'react'
1819

@@ -29,6 +30,16 @@ export const SearchOrAskAiButton = () => {
2930
const isModalOpen = useModalIsOpen()
3031
const { openModal, closeModal, toggleModal } = useModalActions()
3132

33+
const { data: isApiAvailable } = useQuery({
34+
queryKey: ['api-health'],
35+
queryFn: async () => {
36+
const response = await fetch('/docs/_api/v1/', { method: 'HEAD' })
37+
return response.ok
38+
},
39+
staleTime: 5 * 60 * 1000, // 5 minutes
40+
retry: false,
41+
})
42+
3243
const positionCss = css`
3344
position: absolute;
3445
left: 50%;
@@ -62,6 +73,10 @@ export const SearchOrAskAiButton = () => {
6273
}
6374
}, [])
6475

76+
if (!isApiAvailable) {
77+
return null
78+
}
79+
6580
return (
6681
<>
6782
<EuiButton

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public static class MappingsExtension
1515
{
1616
public static void MapElasticDocsApiEndpoints(this IEndpointRouteBuilder group)
1717
{
18+
_ = group.MapMethods("/", [HttpMethods.Head], () => Results.Empty);
1819
MapAskAiEndpoint(group);
1920
MapSearchEndpoint(group);
2021
}

0 commit comments

Comments
 (0)