diff --git a/.build_number b/.build_number index 2c2c772..c1c622e 100644 --- a/.build_number +++ b/.build_number @@ -1 +1 @@ -251260501 \ No newline at end of file +251261817 diff --git a/backend/app/routers/branding.py b/backend/app/routers/branding.py index 225776a..a01ae85 100644 --- a/backend/app/routers/branding.py +++ b/backend/app/routers/branding.py @@ -14,6 +14,7 @@ _FAVICON_PATH = os.path.join(_BRANDING_DIR, "favicon.ico") _BUNDLED_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "assets", "branding")) _BUNDLED_LOGO_PATH = os.path.join(_BUNDLED_DIR, "logo.png") _BUNDLED_FAVICON_PATH = os.path.join(_BUNDLED_DIR, "favicon.ico") +_BRANDING_SOURCE = os.getenv("BRANDING_SOURCE", "bundled").lower() def _ensure_branding_dir() -> None: @@ -80,24 +81,32 @@ def _ensure_default_branding() -> None: favicon.save(_FAVICON_PATH, format="ICO") +def _resolve_branding_paths() -> tuple[str, str]: + if _BRANDING_SOURCE == "data": + _ensure_default_branding() + return _LOGO_PATH, _FAVICON_PATH + if os.path.exists(_BUNDLED_LOGO_PATH) and os.path.exists(_BUNDLED_FAVICON_PATH): + return _BUNDLED_LOGO_PATH, _BUNDLED_FAVICON_PATH + _ensure_default_branding() + return _LOGO_PATH, _FAVICON_PATH + + @router.get("/logo.png") async def branding_logo() -> FileResponse: - if not os.path.exists(_LOGO_PATH): - _ensure_default_branding() - if not os.path.exists(_LOGO_PATH): + logo_path, _ = _resolve_branding_paths() + if not os.path.exists(logo_path): raise HTTPException(status_code=404, detail="Logo not found") - headers = {"Cache-Control": "public, max-age=300"} - return FileResponse(_LOGO_PATH, media_type="image/png", headers=headers) + headers = {"Cache-Control": "no-store"} + return FileResponse(logo_path, media_type="image/png", headers=headers) @router.get("/favicon.ico") async def branding_favicon() -> FileResponse: - if not os.path.exists(_FAVICON_PATH): - _ensure_default_branding() - if not os.path.exists(_FAVICON_PATH): + _, favicon_path = _resolve_branding_paths() + if not os.path.exists(favicon_path): raise HTTPException(status_code=404, detail="Favicon not found") - headers = {"Cache-Control": "public, max-age=300"} - return FileResponse(_FAVICON_PATH, media_type="image/x-icon", headers=headers) + headers = {"Cache-Control": "no-store"} + return FileResponse(favicon_path, media_type="image/x-icon", headers=headers) async def save_branding_image(file: UploadFile) -> Dict[str, Any]: