From c5ad0e6eca9706cae34582b5e56c3f99c7eeddd8 Mon Sep 17 00:00:00 2001 From: Erik Michelson Date: Thu, 17 Dec 2020 23:30:18 +0100 Subject: [PATCH] Fix bug that pathname is always empty (#859) --- src/hooks/common/use-frontend-base-url.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hooks/common/use-frontend-base-url.ts b/src/hooks/common/use-frontend-base-url.ts index c11cd6e03..35eda38c9 100644 --- a/src/hooks/common/use-frontend-base-url.ts +++ b/src/hooks/common/use-frontend-base-url.ts @@ -8,6 +8,8 @@ import { useLocation } from 'react-router' export const useFrontendBaseUrl = (): string => { const { pathname } = useLocation() + const location = window.location + const cleanedPathName = location.pathname.replace(pathname, '') - return window.location.pathname.replace(pathname, '') + return `${location.protocol}//${location.host}${cleanedPathName}` }