fix: remove some redundant basePath calls

This commit is contained in:
gauthier-th
2025-05-27 17:24:43 +02:00
parent 9d9ce8072a
commit 89c4e119fe
6 changed files with 44 additions and 50 deletions

View File

@@ -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 */}
<img
src="/os_icon.svg"
src={basePath + '/os_icon.svg'}
alt={settings.currentSettings.applicationTitle}
className="mr-2 h-5"
/>

View File

@@ -3,153 +3,154 @@ interface PWAHeaderProps {
}
const PWAHeader = ({ applicationTitle = 'Jellyseerr' }: PWAHeaderProps) => {
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || '';
return (
<>
<link
rel="apple-touch-icon"
sizes="180x180"
href="/apple-touch-icon.png"
href={`${basePath}/apple-touch-icon.png`}
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="/favicon-32x32.png"
href={`${basePath}/favicon-32x32.png`}
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="/favicon-16x16.png"
href={`${basePath}/favicon-16x16.png`}
/>
<link
rel="apple-touch-startup-image"
href="/apple-splash-2048-2732.jpg"
href={`${basePath}/apple-splash-2048-2732.jpg`}
media="(device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)"
/>
<link
rel="apple-touch-startup-image"
href="/apple-splash-2732-2048.jpg"
href={`${basePath}/apple-splash-2732-2048.jpg`}
media="(device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)"
/>
<link
rel="apple-touch-startup-image"
href="/apple-splash-1668-2388.jpg"
href={`${basePath}/apple-splash-1668-2388.jpg`}
media="(device-width: 834px) and (device-height: 1194px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)"
/>
<link
rel="apple-touch-startup-image"
href="/apple-splash-2388-1668.jpg"
href={`${basePath}/apple-splash-2388-1668.jpg`}
media="(device-width: 834px) and (device-height: 1194px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)"
/>
<link
rel="apple-touch-startup-image"
href="/apple-splash-1536-2048.jpg"
href={`${basePath}/apple-splash-1536-2048.jpg`}
media="(device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)"
/>
<link
rel="apple-touch-startup-image"
href="/apple-splash-2048-1536.jpg"
href={`${basePath}/apple-splash-2048-1536.jpg`}
media="(device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)"
/>
<link
rel="apple-touch-startup-image"
href="/apple-splash-1668-2224.jpg"
href={`${basePath}/apple-splash-1668-2224.jpg`}
media="(device-width: 834px) and (device-height: 1112px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)"
/>
<link
rel="apple-touch-startup-image"
href="/apple-splash-2224-1668.jpg"
href={`${basePath}/apple-splash-2224-1668.jpg`}
media="(device-width: 834px) and (device-height: 1112px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)"
/>
<link
rel="apple-touch-startup-image"
href="/apple-splash-1620-2160.jpg"
href={`${basePath}/apple-splash-1620-2160.jpg`}
media="(device-width: 810px) and (device-height: 1080px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)"
/>
<link
rel="apple-touch-startup-image"
href="/apple-splash-2160-1620.jpg"
href={`${basePath}/apple-splash-2160-1620.jpg`}
media="(device-width: 810px) and (device-height: 1080px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)"
/>
<link
rel="apple-touch-startup-image"
href="/apple-splash-1284-2778.jpg"
href={`${basePath}/apple-splash-1284-2778.jpg`}
media="(device-width: 428px) and (device-height: 926px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)"
/>
<link
rel="apple-touch-startup-image"
href="/apple-splash-2778-1284.jpg"
href={`${basePath}/apple-splash-2778-1284.jpg`}
media="(device-width: 428px) and (device-height: 926px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)"
/>
<link
rel="apple-touch-startup-image"
href="/apple-splash-1170-2532.jpg"
href={`${basePath}/apple-splash-1170-2532.jpg`}
media="(device-width: 390px) and (device-height: 844px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)"
/>
<link
rel="apple-touch-startup-image"
href="/apple-splash-2532-1170.jpg"
href={`${basePath}/apple-splash-2532-1170.jpg`}
media="(device-width: 390px) and (device-height: 844px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)"
/>
<link
rel="apple-touch-startup-image"
href="/apple-splash-1125-2436.jpg"
href={`${basePath}/apple-splash-1125-2436.jpg`}
media="(device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)"
/>
<link
rel="apple-touch-startup-image"
href="/apple-splash-2436-1125.jpg"
href={`${basePath}/apple-splash-2436-1125.jpg`}
media="(device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)"
/>
<link
rel="apple-touch-startup-image"
href="/apple-splash-1242-2688.jpg"
href={`${basePath}/apple-splash-1242-2688.jpg`}
media="(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)"
/>
<link
rel="apple-touch-startup-image"
href="/apple-splash-2688-1242.jpg"
href={`${basePath}/apple-splash-2688-1242.jpg`}
media="(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)"
/>
<link
rel="apple-touch-startup-image"
href="/apple-splash-828-1792.jpg"
href={`${basePath}/apple-splash-828-1792.jpg`}
media="(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)"
/>
<link
rel="apple-touch-startup-image"
href="/apple-splash-1792-828.jpg"
href={`${basePath}/apple-splash-1792-828.jpg`}
media="(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)"
/>
<link
rel="apple-touch-startup-image"
href="/apple-splash-1242-2208.jpg"
href={`${basePath}/apple-splash-1242-2208.jpg`}
media="(device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)"
/>
<link
rel="apple-touch-startup-image"
href="/apple-splash-2208-1242.jpg"
href={`${basePath}/apple-splash-2208-1242.jpg`}
media="(device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)"
/>
<link
rel="apple-touch-startup-image"
href="/apple-splash-750-1334.jpg"
href={`${basePath}/apple-splash-750-1334.jpg`}
media="(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)"
/>
<link
rel="apple-touch-startup-image"
href="/apple-splash-1334-750.jpg"
href={`${basePath}/apple-splash-1334-750.jpg`}
media="(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)"
/>
<link
rel="apple-touch-startup-image"
href="/apple-splash-640-1136.jpg"
href={`${basePath}/apple-splash-640-1136.jpg`}
media="(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)"
/>
<link
rel="apple-touch-startup-image"
href="/apple-splash-1136-640.jpg"
href={`${basePath}/apple-splash-1136-640.jpg`}
media="(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)"
/>
<meta name="apple-mobile-web-app-capable" content="yes" />
@@ -159,7 +160,7 @@ const PWAHeader = ({ applicationTitle = 'Jellyseerr' }: PWAHeaderProps) => {
/>
<link
rel="manifest"
href="/site.webmanifest"
href={`${basePath}/site.webmanifest`}
crossOrigin="use-credentials"
/>
<meta name="apple-mobile-web-app-title" content={applicationTitle} />

View File

@@ -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, string> = {
[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]: '',
};

View File

@@ -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}</>;
};

View File

@@ -58,7 +58,6 @@ const useDiscover = <
): DiscoverResult<T, S> => {
const settings = useSettings();
const { hasPermission } = useUser();
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || '';
const { data, error, size, setSize, isValidating, mutate } = useSWRInfinite<
BaseSearchResult<T> & S
>(
@@ -79,9 +78,7 @@ const useDiscover = <
)
.join('&');
const fullEndpoint = endpoint.startsWith('/')
? `${basePath}${endpoint}`
: endpoint;
const fullEndpoint = endpoint.startsWith('/') ? `${endpoint}` : endpoint;
return `${fullEndpoint}?${finalQueryString}`;
},
{

View File

@@ -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]);