From 07fd43a5edba7c8f44bc79b934e9607fa99c4399 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 19 May 2026 13:39:37 +0000 Subject: [PATCH] Add GEMINI_API_KEY env var fallback for TTS Add GEMINI_API_KEY to docker-compose so it can be set in Portainer. Fall back to this env var when the DB app_config has no geminiApiKey, so Gemini TTS works without requiring the user to save the key through the Settings UI. https://claude.ai/code/session_01QBvwHAMZzVYfWvy1U5paat --- docker-compose.yml | 1 + server/routes/reels.ts | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 9d859cd..97c95f8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -36,6 +36,7 @@ services: PORT: 5555 DATABASE_URL: postgresql://${PGUSER:-socialflow}:${PGPASSWORD:-changeme}@postgres:4523/${PGDATABASE:-socialflow} OPENROUTER_API_KEY: ${OPENROUTER_API_KEY} + GEMINI_API_KEY: ${GEMINI_API_KEY} SESSION_SECRET: ${SESSION_SECRET:-your-secret-key-change-me} APP_URL: ${APP_URL:-http://localhost:5555} # URL interne Docker pour que ffmpeg-api puisse télécharger les fichiers audio diff --git a/server/routes/reels.ts b/server/routes/reels.ts index 2eef9a2..3d9407d 100644 --- a/server/routes/reels.ts +++ b/server/routes/reels.ts @@ -324,7 +324,7 @@ reelsRouter.post('/reels/preview', async (req: Request, res: Response) => { let geminiApiKey: string | undefined = undefined; if (ttsEngine === "gemini") { const appCfg = await storage.getAppConfig(); - geminiApiKey = appCfg?.geminiApiKey ?? undefined; + geminiApiKey = appCfg?.geminiApiKey ?? process.env.GEMINI_API_KEY ?? undefined; } const finalWordDuration = wordDuration; @@ -378,7 +378,7 @@ reelsRouter.post('/reels/tts-preview', async (req: Request, res: Response) => { let geminiApiKey: string | undefined = undefined; if (ttsEngine === "gemini") { const appCfg = await storage.getAppConfig(); - geminiApiKey = appCfg?.geminiApiKey ?? undefined; + geminiApiKey = appCfg?.geminiApiKey ?? process.env.GEMINI_API_KEY ?? undefined; } const result = await ffmpegService.previewTTS(text, ttsVoice, ttsEngine, geminiApiKey); @@ -566,7 +566,7 @@ async function processReelBackground( let geminiApiKey: string | undefined = undefined; if (ttsEngine === "gemini") { const appCfg = await storage.getAppConfig(); - geminiApiKey = appCfg?.geminiApiKey ?? undefined; + geminiApiKey = appCfg?.geminiApiKey ?? process.env.GEMINI_API_KEY ?? undefined; } const finalWordDuration = wordDuration ?? 0.6;