diff --git a/src/components/Login/index.tsx b/src/components/Login/index.tsx index 73d2748f2..ccab512ca 100644 --- a/src/components/Login/index.tsx +++ b/src/components/Login/index.tsx @@ -45,6 +45,8 @@ const Login = () => { settings.currentSettings.mediaServerLogin ); + const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ''; + // Effect that is triggered when the `authToken` comes back from the Plex OAuth // We take the token and attempt to sign in. If we get a success message, we will // ask swr to revalidate the user which _should_ come back with a valid user. @@ -130,7 +132,7 @@ const Login = () => { > {/* eslint-disable-next-line @next/next/no-img-element */} {settings.currentSettings.applicationTitle} diff --git a/src/components/PWAHeader/index.tsx b/src/components/PWAHeader/index.tsx index 777b63e0c..1ab4f9c0c 100644 --- a/src/components/PWAHeader/index.tsx +++ b/src/components/PWAHeader/index.tsx @@ -3,153 +3,154 @@ interface PWAHeaderProps { } const PWAHeader = ({ applicationTitle = 'Jellyseerr' }: PWAHeaderProps) => { + const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ''; return ( <> @@ -159,7 +160,7 @@ const PWAHeader = ({ applicationTitle = 'Jellyseerr' }: PWAHeaderProps) => { /> diff --git a/src/components/Setup/index.tsx b/src/components/Setup/index.tsx index 72424b58f..e00c43813 100644 --- a/src/components/Setup/index.tsx +++ b/src/components/Setup/index.tsx @@ -66,7 +66,7 @@ const Setup = () => { setIsUpdating(false); if (response.data.initialized) { await axios.post('/api/v1/settings/main', { locale }); - mutate(getBasedPath('/api/v1/settings/public')); + mutate('/api/v1/settings/public'); router.push('/'); } @@ -75,9 +75,9 @@ const Setup = () => { const validateLibraries = useCallback(async () => { try { const endpointMap: Record = { - [MediaServerType.JELLYFIN]: getBasedPath('/api/v1/settings/jellyfin'), - [MediaServerType.EMBY]: getBasedPath('/api/v1/settings/jellyfin'), - [MediaServerType.PLEX]: getBasedPath('/api/v1/settings/plex'), + [MediaServerType.JELLYFIN]: '/api/v1/settings/jellyfin', + [MediaServerType.EMBY]: '/api/v1/settings/jellyfin', + [MediaServerType.PLEX]: '/api/v1/settings/plex', [MediaServerType.NOT_CONFIGURED]: '', }; diff --git a/src/context/UserContext.tsx b/src/context/UserContext.tsx index 74838431d..8400132f3 100644 --- a/src/context/UserContext.tsx +++ b/src/context/UserContext.tsx @@ -32,7 +32,7 @@ export const UserContext = ({ initialUser, children }: UserContextProps) => { routing.current = true; location.href = `${API_BASE}/login`; } - }, [router, user, error]); + }, [router, user, error, API_BASE]); return <>{children}; }; diff --git a/src/hooks/useDiscover.ts b/src/hooks/useDiscover.ts index 83f1eee36..850e95811 100644 --- a/src/hooks/useDiscover.ts +++ b/src/hooks/useDiscover.ts @@ -58,7 +58,6 @@ const useDiscover = < ): DiscoverResult => { const settings = useSettings(); const { hasPermission } = useUser(); - const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ''; const { data, error, size, setSize, isValidating, mutate } = useSWRInfinite< BaseSearchResult & S >( @@ -79,9 +78,7 @@ const useDiscover = < ) .join('&'); - const fullEndpoint = endpoint.startsWith('/') - ? `${basePath}${endpoint}` - : endpoint; + const fullEndpoint = endpoint.startsWith('/') ? `${endpoint}` : endpoint; return `${fullEndpoint}?${finalQueryString}`; }, { diff --git a/src/hooks/useSearchInput.ts b/src/hooks/useSearchInput.ts index c21c812a1..a60b28c07 100644 --- a/src/hooks/useSearchInput.ts +++ b/src/hooks/useSearchInput.ts @@ -1,5 +1,4 @@ /* eslint-disable react-hooks/exhaustive-deps */ -import { getBasedPath } from '@app/utils/navigationUtil'; import type { Nullable } from '@app/utils/typeHelpers'; import { useRouter } from 'next/router'; import type { Dispatch, SetStateAction } from 'react'; @@ -36,7 +35,7 @@ const useSearchInput = (): SearchObject => { if (debouncedValue !== '' && searchOpen) { if (router.pathname.startsWith('/search')) { router.replace({ - pathname: getBasedPath(router.pathname), + pathname: router.pathname, query: { ...router.query, query: debouncedValue, @@ -46,7 +45,7 @@ const useSearchInput = (): SearchObject => { setLastRoute(router.asPath); router .push({ - pathname: getBasedPath('/search'), + pathname: '/search', query: { query: debouncedValue }, }) .then(() => window.scrollTo(0, 0)); @@ -67,14 +66,9 @@ const useSearchInput = (): SearchObject => { !searchOpen ) { if (lastRoute) { - const route = - typeof lastRoute === 'string' - ? getBasedPath(lastRoute) - : getBasedPath(lastRoute.pathname || '/'); - - router.push(route).then(() => window.scrollTo(0, 0)); + router.push(lastRoute).then(() => window.scrollTo(0, 0)); } else { - router.replace(getBasedPath('/')).then(() => window.scrollTo(0, 0)); + router.replace('/').then(() => window.scrollTo(0, 0)); } } }, [searchOpen]);