diff --git a/src/components/layout/header/Search.tsx b/src/components/layout/header/Search.tsx index e0de950b2b8..a49085a6a63 100644 --- a/src/components/layout/header/Search.tsx +++ b/src/components/layout/header/Search.tsx @@ -13,6 +13,7 @@ import { useTranslation } from 'next-i18next'; import { useRouter } from 'next/router'; import { ReactNode, forwardRef, useMemo, useRef, useState } from 'react'; import { useConfigContext } from '~/config/provider'; +import { useGetExternalUrl } from '~/hooks/useExternalUrl'; import { api } from '~/utils/api'; import { MovieModal } from './Search/MovieModal'; @@ -141,6 +142,7 @@ const getItemComponent = (icon: SearchAutoCompleteItem['icon']) => { const useConfigApps = (search: string) => { const { config } = useConfigContext(); + const getHref = useGetExternalUrl(); return useMemo(() => { if (search.trim().length === 0) return []; const apps = config?.apps.filter((app) => @@ -153,7 +155,7 @@ const useConfigApps = (search: string) => { value: app.name, sort: 'app', metaData: { - url: app.behaviour.externalUrl, + url: getHref(app), }, })) ?? [] ); diff --git a/src/hooks/useExternalUrl.ts b/src/hooks/useExternalUrl.ts index bbd774220e1..c992a11f224 100644 --- a/src/hooks/useExternalUrl.ts +++ b/src/hooks/useExternalUrl.ts @@ -3,6 +3,10 @@ import * as tldts from 'tldts'; import { AppType } from '~/types/app'; export const useGetExternalUrl = () => { + if (typeof window === 'undefined') { + return (appType: AppType) => appType.behaviour.externalUrl || appType.url; + } + const parsedUrl = useMemo(() => { try { return tldts.parse(window.location.toString());