Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
feat: runtime .env
Gabriel Steinc8ac86f4147f
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.jsindex cdb68f539..f4a963e30 100644--- a/src/helpers/ipcHandlers.js+++ b/src/helpers/ipcHandlers.js@@ -1005,10 +1005,22 @@ class IPCHandlers {// --- OpenWhispr Cloud API handlers ---+ // In production, VITE_* env vars aren't available in the main process because+ // Vite only inlines them into the renderer bundle at build time. Load the+ // runtime-env.json that the Vite build writes to src/dist/ as a fallback.+ const runtimeEnv = (() => {+ const fs = require("fs");+ const envPath = path.join(__dirname, "..", "dist", "runtime-env.json");+ try {+ if (fs.existsSync(envPath)) return JSON.parse(fs.readFileSync(envPath, "utf8"));+ } catch {}+ return {};+ })();+const getApiUrl = () =>- process.env.OPENWHISPR_API_URL || process.env.VITE_OPENWHISPR_API_URL || "";+ process.env.OPENWHISPR_API_URL || process.env.VITE_OPENWHISPR_API_URL || runtimeEnv.VITE_OPENWHISPR_API_URL || "";- const getAuthUrl = () => process.env.NEON_AUTH_URL || process.env.VITE_NEON_AUTH_URL || "";+ const getAuthUrl = () => process.env.NEON_AUTH_URL || process.env.VITE_NEON_AUTH_URL || runtimeEnv.VITE_NEON_AUTH_URL || "";const getSessionCookies = async (event) => {const win = BrowserWindow.fromWebContents(event.sender);diff --git a/src/vite.config.mjs b/src/vite.config.mjsindex 1083236cb..997a75cb1 100644--- a/src/vite.config.mjs+++ b/src/vite.config.mjs@@ -2,6 +2,7 @@ import { defineConfig, loadEnv } from 'vite'import react from '@vitejs/plugin-react'import tailwindcss from '@tailwindcss/vite'import path from 'path'+import fs from 'fs'import { fileURLToPath } from 'url'const __filename = fileURLToPath(import.meta.url)@@ -27,7 +28,23 @@ export default defineConfig(({ mode }) => {const devServerPort = parseDevServerPort(rawPort)return {- plugins: [react(), tailwindcss()],+ plugins: [+ react(),+ tailwindcss(),+ {+ name: 'write-runtime-env',+ writeBundle() {+ const runtimeEnv = {+ VITE_OPENWHISPR_API_URL: env.VITE_OPENWHISPR_API_URL || '',+ VITE_NEON_AUTH_URL: env.VITE_NEON_AUTH_URL || '',+ }+ fs.writeFileSync(+ path.resolve(__dirname, 'dist', 'runtime-env.json'),+ JSON.stringify(runtimeEnv)+ )+ },+ },+ ],base: './', // Use relative paths for file:// protocol in ElectronenvDir, // Load .env from project rootresolve: {