File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
Elastic.Documentation.Site/Assets/web-components/SearchOrAskAi
api/Elastic.Documentation.Api.Infrastructure Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import {
1313 EuiLoadingSpinner ,
1414} from '@elastic/eui'
1515import { css } from '@emotion/react'
16+ import { useQuery } from '@tanstack/react-query'
1617import * as React from 'react'
1718import { 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
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments