diff --git a/vite.config.ts b/vite.config.ts index aa08414..3f0f20e 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,11 +2,18 @@ import react from '@vitejs/plugin-react' import { defineConfig, loadEnv } from 'vite' export default ({ mode }) => { - // Load app-level env vars to node-level env vars. - process.env = { ...process.env, ...loadEnv(mode, process.cwd()) } + // Load environment variables and expose them as Vite environment variables + const env = loadEnv(mode, process.cwd()) return defineConfig({ base: '/RubyLive/', plugins: [react()], + define: { + // Explicitly define the variables you want to inject into the build + 'process.env': process.env, // This ensures Node-level env vars are accessible if needed + 'import.meta.env.VITE_OPENAI_API_KEY': JSON.stringify(env.VITE_OPENAI_API_KEY), + 'import.meta.env.VITE_SIMLI_API_KEY': JSON.stringify(env.VITE_SIMLI_API_KEY), + 'import.meta.env.VITE_ELEVENLABS_API_KEY': JSON.stringify(env.VITE_ELEVENLABS_API_KEY), + }, }) }