From 3f5f610e35a321b0c4ec6779012cb5731827e0d9 Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Wed, 11 Jun 2025 10:26:36 +0800 Subject: [PATCH] move API url to config --- next-ui/.env.development | 1 + next-ui/src/api/komga-client.ts | 2 +- next-ui/src/vite-env.d.ts | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 next-ui/.env.development create mode 100644 next-ui/src/vite-env.d.ts diff --git a/next-ui/.env.development b/next-ui/.env.development new file mode 100644 index 00000000..df672c46 --- /dev/null +++ b/next-ui/.env.development @@ -0,0 +1 @@ +VITE_KOMGA_API_URL=http://localhost:8080 diff --git a/next-ui/src/api/komga-client.ts b/next-ui/src/api/komga-client.ts index 4e7f24bc..b2f9151a 100644 --- a/next-ui/src/api/komga-client.ts +++ b/next-ui/src/api/komga-client.ts @@ -35,7 +35,7 @@ const coladaMiddleware: Middleware = { } const client = createClient({ - baseUrl: 'http://localhost:8080', + baseUrl: import.meta.env.VITE_KOMGA_API_URL, // required to pass the session cookie on all requests credentials: 'include', // required to avoid browser basic-auth popups diff --git a/next-ui/src/vite-env.d.ts b/next-ui/src/vite-env.d.ts new file mode 100644 index 00000000..eae3ada0 --- /dev/null +++ b/next-ui/src/vite-env.d.ts @@ -0,0 +1,15 @@ +/// + +interface ViteTypeOptions { + // By adding this line, you can make the type of ImportMetaEnv strict + // to disallow unknown keys. + strictImportMetaEnv: unknown +} + +interface ImportMetaEnv { + readonly VITE_KOMGA_API_URL: string +} + +interface ImportMeta { + readonly env: ImportMetaEnv +}