feat(desktop): bridge MAIN_VITE_API_URL to process.env for packaged builds
In packaged Electron builds, @multica/core is externalized and .env files are excluded. Bridge import.meta.env.MAIN_VITE_API_URL (injected at build time by electron-vite) to process.env.MULTICA_API_URL so that getApiBaseUrl() reads the correct value in staging/test environments. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
b8aa5ad7e6
commit
b7477cb646
2 changed files with 8 additions and 0 deletions
1
apps/desktop/src/main/electron-env.d.ts
vendored
1
apps/desktop/src/main/electron-env.d.ts
vendored
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue