From cc1c1ff6d5c6d86750c2ff5c4020bbdb21df325b Mon Sep 17 00:00:00 2001 From: sai80082 Date: Wed, 28 Aug 2024 14:37:54 +0530 Subject: [PATCH] chore: Implement redirection to external Immich URL if set --- src/components/people/PersonItem.tsx | 4 ++-- src/config/environment.ts | 1 + src/contexts/ConfigContext.tsx | 2 ++ src/pages/_app.tsx | 2 ++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/people/PersonItem.tsx b/src/components/people/PersonItem.tsx index 39f0c0f..fc04f64 100644 --- a/src/components/people/PersonItem.tsx +++ b/src/components/people/PersonItem.tsx @@ -18,7 +18,7 @@ interface IProps { onRemove: (person: IPerson) => void; } export default function PersonItem({ person, onRemove }: IProps) { - const { immichURL } = useConfig(); + const { exImmichUrl } = useConfig(); const { toast } = useToast(); const [editMode, setEditMode] = useState(false); const [loading, setLoading] = useState(false); @@ -98,7 +98,7 @@ export default function PersonItem({ person, onRemove }: IProps) {
diff --git a/src/config/environment.ts b/src/config/environment.ts index 8694183..f0972b5 100644 --- a/src/config/environment.ts +++ b/src/config/environment.ts @@ -1,5 +1,6 @@ export const ENV = { IMMICH_URL: (process.env.IMMICH_URL || 'http://immich_server:3001') as string, + EXTERNAL_IMMICH_URL: (process.env.EXTERNAL_IMMICH_URL || process.env.IMMICH_URL) as string, IMMICH_API_KEY: process.env.IMMICH_API_KEY as string, DATABASE_URL: (process.env.DATABASE_URL || `postgresql://${process.env.DB_USERNAME}:${process.env.DB_PASSWORD}@${(process.env.DB_HOST || 'immich_postgres')}:${(process.env.DB_PORT || '5432')}/${process.env.DB_DATABASE_NAME}`), }; diff --git a/src/contexts/ConfigContext.tsx b/src/contexts/ConfigContext.tsx index 53de163..9c742cf 100644 --- a/src/contexts/ConfigContext.tsx +++ b/src/contexts/ConfigContext.tsx @@ -2,10 +2,12 @@ import { createContext, useContext } from "react"; interface ConfigContextType { immichURL: string; + exImmichUrl: string; } const ConfigContext = createContext({ immichURL: "", + exImmichUrl: "", }); export default ConfigContext; diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 7ecce1c..f90289b 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -10,6 +10,7 @@ import { getMe } from "@/handlers/api/user.handler"; interface AppPropsWithProps extends AppProps { props: { immichURL: string; + exImmichUrl: string; }; } const App = ({ Component, pageProps, ...props }: AppPropsWithProps) => { @@ -29,6 +30,7 @@ const App = ({ Component, pageProps, ...props }: AppPropsWithProps) => { App.getInitialProps = async () => { return { props: { + exImmichUrl: ENV.EXTERNAL_IMMICH_URL, immichURL: ENV.IMMICH_URL, }, };