From 1854cce64ebeb7570861485b787e7e37d356037c Mon Sep 17 00:00:00 2001 From: jffarge Date: Tue, 29 Jun 2021 22:44:44 +0200 Subject: [PATCH] docs: :bug: disable authentication for algolia docsearch crawler Signed-off-by: jffarge --- website/src/theme/DocPage/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/website/src/theme/DocPage/index.js b/website/src/theme/DocPage/index.js index a6b318e9..f0f4037a 100644 --- a/website/src/theme/DocPage/index.js +++ b/website/src/theme/DocPage/index.js @@ -26,6 +26,7 @@ import { GithubLoginButton } from 'react-social-login-buttons'; import Spinner from '../../components/Spinner'; import DocPageAuthentication from '../../components/DocPageAuthentication'; import DocPageRedirect from '../../components/DocPageRedirect'; +import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment'; function DocPageContent({ currentDocRoute, versionMetadata, children }) { const { siteConfig, isClient } = useDocusaurusContext(); @@ -138,9 +139,10 @@ function DocPage(props) { const currentDocRoute = docRoutes.find((docRoute) => matchPath(location.pathname, docRoute), ); + const userAgent = ExecutionEnvironment.canUseDOM ? navigator.userAgent : null; // CUSTOM DOCPAGE - if (process.env.OAUTH_ENABLE == 'true') { + if (process.env.OAUTH_ENABLE == 'true' && userAgent !== 'Algolia DocSearch Crawler') { const [isLoading, setIsLoading] = useState(true) const [redirectState, setRedirectState] = useState() const authQuery = qs.parse(location.search);