This is an automated email from the ASF dual-hosted git repository. shuai pushed a commit to branch feat/baseurl in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
commit 7946cea31d6efb5adb64bc9c3b32b814387b58bf Author: shuai <[email protected]> AuthorDate: Mon Mar 25 15:40:43 2024 +0800 fix: base url --- ui/src/components/Share/index.tsx | 5 +++-- ui/src/pages/Install/index.tsx | 3 ++- ui/src/pages/Users/Logout/index.tsx | 4 ++-- ui/src/router/alias.ts | 2 ++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ui/src/components/Share/index.tsx b/ui/src/components/Share/index.tsx index 0cd46f36..203a72d6 100644 --- a/ui/src/components/Share/index.tsx +++ b/ui/src/components/Share/index.tsx @@ -24,6 +24,7 @@ import { useTranslation } from 'react-i18next'; import { FacebookShareButton, TwitterShareButton } from 'next-share'; import copy from 'copy-to-clipboard'; +import { BASE_ORIGIN } from '@/router/alias'; import { loggedUserInfoStore } from '@/stores'; interface IProps { @@ -42,8 +43,8 @@ const Index: FC<IProps> = ({ type, qid, aid, title }) => { const { t } = useTranslation(); let baseUrl = type === 'question' - ? `${window.location.origin}/questions/${qid}` - : `${window.location.origin}/questions/${qid}/${aid}`; + ? `${BASE_ORIGIN}/questions/${qid}` + : `${BASE_ORIGIN}/questions/${qid}/${aid}`; if (user.id) { baseUrl = `${baseUrl}?shareUserId=${user.username}`; } diff --git a/ui/src/pages/Install/index.tsx b/ui/src/pages/Install/index.tsx index 69723d29..39d24d09 100644 --- a/ui/src/pages/Install/index.tsx +++ b/ui/src/pages/Install/index.tsx @@ -31,6 +31,7 @@ import { } from '@/services'; import { Storage, handleFormError, scrollToDocTop } from '@/utils'; import { CURRENT_LANG_STORAGE_KEY } from '@/common/constants'; +import { BASE_ORIGIN } from '@/router/alias'; import { FirstStep, @@ -94,7 +95,7 @@ const Index: FC = () => { errorMsg: '', }, site_url: { - value: window.location.origin, + value: BASE_ORIGIN, isInvalid: false, errorMsg: '', }, diff --git a/ui/src/pages/Users/Logout/index.tsx b/ui/src/pages/Users/Logout/index.tsx index 9da6e59d..5561c16f 100644 --- a/ui/src/pages/Users/Logout/index.tsx +++ b/ui/src/pages/Users/Logout/index.tsx @@ -25,7 +25,7 @@ import { usePageTags } from '@/hooks'; import { logout } from '@/services'; import { loggedUserInfoStore } from '@/stores'; import Storage from '@/utils/storage'; -import { RouteAlias } from '@/router/alias'; +import { RouteAlias, BASE_ORIGIN } from '@/router/alias'; import { REDIRECT_PATH_STORAGE_KEY } from '@/common/constants'; const Index = () => { @@ -43,7 +43,7 @@ const Index = () => { const redirect = Storage.get(REDIRECT_PATH_STORAGE_KEY) || RouteAlias.home; Storage.remove(REDIRECT_PATH_STORAGE_KEY); - window.location.replace(`${window.location.origin}${redirect}`); + window.location.replace(`${BASE_ORIGIN}${redirect}`); }); } // auto height of container diff --git a/ui/src/router/alias.ts b/ui/src/router/alias.ts index 050f6c74..5f765b22 100644 --- a/ui/src/router/alias.ts +++ b/ui/src/router/alias.ts @@ -19,6 +19,8 @@ export const REACT_BASE_PATH = process.env.REACT_APP_BASE_URL || ''; +export const BASE_ORIGIN = `${window.location.origin}${REACT_BASE_PATH}`; + export const RouteAlias = { home: '/', login: '/users/login',
