From 92801b91563d6d201f7ef0da40f26d0035b5d26c Mon Sep 17 00:00:00 2001 From: TheAchiever6823 <61914223+ShawnMadadha@users.noreply.github.com> Date: Mon, 18 May 2026 00:55:29 -0700 Subject: [PATCH] [shawn] fix: load backend/.env at startup so Telegram listener gets API creds in dev --- backend/main.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/backend/main.py b/backend/main.py index 822e0fbd..2d1d458d 100644 --- a/backend/main.py +++ b/backend/main.py @@ -2,8 +2,19 @@ import asyncio import html import logging import os +from pathlib import Path from uuid import uuid4 +# Load backend/.env before any module reads os.environ. Production builds +# (DMG/EXE) get env vars injected by Electron at spawn so this is a no-op +# there. In dev mode (`bash run.sh`) this is the only thing pulling .env +# values into the process — OPENSWARM_TELEGRAM_API_ID, GOOGLE_OAUTH_*, etc. +try: + from dotenv import load_dotenv as _load_dotenv + _load_dotenv(Path(__file__).parent / ".env") +except Exception: # noqa: BLE001 + pass + logger = logging.getLogger(__name__) from fastapi.responses import JSONResponse, HTMLResponse