diff --git a/src/components/BackButton.tsx b/src/components/BackButton.tsx index 01dbcbfdc..575a08c27 100644 --- a/src/components/BackButton.tsx +++ b/src/components/BackButton.tsx @@ -1,7 +1,9 @@ +import { env } from '@/env.mjs' import useIsInIframe from '@/hooks/useIsInIframe' import { useLocation } from '@/stores/location' import { getCurrentUrlOrigin } from '@/utils/links' import { useRouter } from 'next/router' +import urlJoin from 'url-join' import Button, { ButtonProps } from './Button' export type BackButtonProps = ButtonProps & { @@ -24,7 +26,10 @@ export default function BackButton({ const hasBackToCurrentSession = !!prevUrl - const prevUrlPathname = prevUrl?.replace(getCurrentUrlOrigin(), '') + const prevUrlPathname = prevUrl?.replace( + urlJoin(getCurrentUrlOrigin(), env.NEXT_PUBLIC_BASE_PATH), + '' + ) let isDefaultBackLinkSameAsPrevUrl = defaultBackLink === prevUrlPathname if (homeLinks.includes(defaultBackLink)) { isDefaultBackLinkSameAsPrevUrl = homeLinks.includes(prevUrlPathname ?? '') diff --git a/src/utils/links.ts b/src/utils/links.ts index 29ea5e620..185b9c9bf 100644 --- a/src/utils/links.ts +++ b/src/utils/links.ts @@ -37,7 +37,7 @@ function getHubIdFromUrl(currentPath: CurrentPath) { export function getHubPageLink(currentPath: CurrentPath) { const hubId = getHubIdFromUrl(currentPath) const isWidgetRoute = currentPath.pathname?.includes('/widget') - if (!isWidgetRoute) return `/hub/${hubId ?? ''}` + if (!isWidgetRoute) return `/${hubId ?? ''}` return `/widget/${hubId ?? ''}` }