diff --git a/apps/desktop/src/main/electron-env.d.ts b/apps/desktop/src/main/electron-env.d.ts index 58860c2b..da3774b4 100644 --- a/apps/desktop/src/main/electron-env.d.ts +++ b/apps/desktop/src/main/electron-env.d.ts @@ -5,6 +5,7 @@ interface ImportMetaEnv { readonly MAIN_VITE_GATEWAY_URL: string readonly MAIN_VITE_WEB_URL: string + readonly MAIN_VITE_API_URL?: string } interface ImportMeta { diff --git a/apps/desktop/src/main/index.ts b/apps/desktop/src/main/index.ts index f0780a5f..07e362a1 100644 --- a/apps/desktop/src/main/index.ts +++ b/apps/desktop/src/main/index.ts @@ -44,6 +44,13 @@ process.stderr?.on?.('error', (err: NodeJS.ErrnoException) => { throw err }) +// Bridge Vite build-time env to process.env for externalized @multica/core +// In dev mode, electron-vite already loads .env into process.env; +// In packaged builds, only import.meta.env has the value (injected at build time). +if (import.meta.env.MAIN_VITE_API_URL) { + process.env.MULTICA_API_URL ??= import.meta.env.MAIN_VITE_API_URL +} + import { app, BrowserWindow, shell, ipcMain } from 'electron' import { fileURLToPath } from 'node:url' import path from 'node:path'