| """Load .env from backend/ and repo root so one file works from either cwd.""" |
|
|
| from __future__ import annotations |
|
|
| from pathlib import Path |
|
|
| from dotenv import load_dotenv |
|
|
| _BACKEND_DIR = Path(__file__).resolve().parent.parent |
| _REPO_ROOT = _BACKEND_DIR.parent |
|
|
|
|
| def load_app_env() -> None: |
| """Later paths override earlier (most specific wins).""" |
| for path in ( |
| _REPO_ROOT / ".env", |
| _REPO_ROOT / ".env.local", |
| _BACKEND_DIR / ".env", |
| _BACKEND_DIR / ".env.local", |
| ): |
| if path.is_file(): |
| load_dotenv(path, override=True) |
|
|