From c06d9b4e4f2f07406dc3442d3acd523febcda6b0 Mon Sep 17 00:00:00 2001 From: Chris Bartholomew Date: Wed, 7 Jan 2026 03:49:13 -0500 Subject: [PATCH] Load .env file automatically on startup (#104) Add automatic .env file loading using python-dotenv. This searches the current working directory and parent directories for a .env file and loads environment variables from it. Uses override=True so .env file values take precedence over existing shell environment variables, which is the expected behavior when running from a project directory. --- hindsight-api/hindsight_api/config.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hindsight-api/hindsight_api/config.py b/hindsight-api/hindsight_api/config.py index ea55277c..2acac6f1 100644 --- a/hindsight-api/hindsight_api/config.py +++ b/hindsight-api/hindsight_api/config.py @@ -8,6 +8,11 @@ import logging import os from dataclasses import dataclass +from dotenv import find_dotenv, load_dotenv + +# Load .env file, searching current and parent directories (overrides existing env vars) +load_dotenv(find_dotenv(usecwd=True), override=True) + logger = logging.getLogger(__name__) # Environment variable names