From 6d2d71bc07f581cb09727448960ceb80c9d2289e Mon Sep 17 00:00:00 2001 From: Daniel Aronovich Date: Tue, 22 Oct 2024 10:49:50 +0300 Subject: [PATCH] fixed the getproxybasepath and onHistoryServerClick to deal with a gateway --- spark-ui/src/components/AppDrawer/DrawerFooter.tsx | 5 +++-- spark-ui/src/utils/UrlUtils.ts | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/spark-ui/src/components/AppDrawer/DrawerFooter.tsx b/spark-ui/src/components/AppDrawer/DrawerFooter.tsx index 9077612..1c712a6 100644 --- a/spark-ui/src/components/AppDrawer/DrawerFooter.tsx +++ b/spark-ui/src/components/AppDrawer/DrawerFooter.tsx @@ -5,7 +5,7 @@ import { BASE_PATH, IS_HISTORY_SERVER_MODE, } from "../../utils/UrlConsts"; -import { getBaseAppUrl, isDataFlintSaaSUI } from "../../utils/UrlUtils"; +import { getBaseAppUrl, isDataFlintSaaSUI, getProxyBasePath } from "../../utils/UrlUtils"; export default function DrawerFooter({ version }: { version?: string }) { const onSparkUiClick = (): void => { @@ -13,7 +13,8 @@ export default function DrawerFooter({ version }: { version?: string }) { }; const onHistoryServerClick = (): void => { - window.location.href = `${BASE_PATH}/history`; + const basePath = getProxyBasePath(); + window.location.href = basePath; }; return ( diff --git a/spark-ui/src/utils/UrlUtils.ts b/spark-ui/src/utils/UrlUtils.ts index bcd190b..95e156d 100644 --- a/spark-ui/src/utils/UrlUtils.ts +++ b/spark-ui/src/utils/UrlUtils.ts @@ -27,11 +27,11 @@ export function hrefWithoutEndSlash(): string { return fixedUrl; } -export const getProxyBasePath = (): string => - hrefWithoutEndSlash().substring( - 0, - hrefWithoutEndSlash().lastIndexOf("/dataflint"), - ); +export const getProxyBasePath = (): string => { + const url = new URL(window.location.href); + const pathToRemove = /\/history\/[^/]+\/dataflint\/?$/; + return url.origin + url.pathname.replace(pathToRemove, ''); +}; export function getHistoryServerCurrentAppId(): string { const urlSegments = hrefWithoutEndSlash().split("/");