diff --git a/.gitignore b/.gitignore index 2a646092..1f416217 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,5 @@ tests/e2e/screenshots/*.png tmp_* *.d.ts node_modules/ -/app/public/js/* \ No newline at end of file +/app/public/js/* +.jinja_cache/ diff --git a/api/routes/auth.py b/api/routes/auth.py index 79ebcdd6..f7c1d358 100644 --- a/api/routes/auth.py +++ b/api/routes/auth.py @@ -12,6 +12,7 @@ from fastapi.templating import Jinja2Templates from authlib.common.errors import AuthlibBaseError from authlib.integrations.starlette_client import OAuth +from jinja2 import Environment, FileSystemLoader, FileSystemBytecodeCache from starlette.config import Config from api.auth.user_management import validate_and_cache_user @@ -19,7 +20,21 @@ # Router auth_router = APIRouter() TEMPLATES_DIR = str((Path(__file__).resolve().parents[1] / "../app/templates").resolve()) -templates = Jinja2Templates(directory=TEMPLATES_DIR) + +TEMPLATES_CACHE_DIR = "./.jinja_cache" +os.makedirs(TEMPLATES_CACHE_DIR, exist_ok=True) # ✅ ensures the folder exists + +templates = Jinja2Templates( + env=Environment( + loader=FileSystemLoader(TEMPLATES_DIR), + bytecode_cache=FileSystemBytecodeCache( + directory=TEMPLATES_CACHE_DIR, + pattern="%s.cache" + ), + auto_reload=True + ) +) + # ---- Helpers ---- def _get_provider_client(request: Request, provider: str):