From 9fcce3a0a83ee68ca2ce6f0a5d6bbb38125de96d Mon Sep 17 00:00:00 2001 From: "Gan, Jimmy" Date: Fri, 20 Feb 2026 22:21:16 +0800 Subject: [PATCH] Fix proxy env bug in Telegram alert --- dashboard/backend/routers/auth.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/dashboard/backend/routers/auth.py b/dashboard/backend/routers/auth.py index c467a5f..478362d 100644 --- a/dashboard/backend/routers/auth.py +++ b/dashboard/backend/routers/auth.py @@ -1,6 +1,5 @@ from datetime import timedelta import asyncio -import os import httpx from fastapi import APIRouter, Depends, HTTPException, status, Request from pydantic import BaseModel @@ -36,11 +35,11 @@ async def send_failed_login_alert(ip_address: str, username: str, reason: str): return msg = f"🚨 *Dashboard Security Alert* 🚨\nFailed login attempt detected.\n\nšŸ‘¤ User: `{username}`\n🌐 IP: `{ip_address}`\nāŒ Reason: {reason}" try: + client_options = {} if config.TELEGRAM_PROXY: - os.environ["HTTP_PROXY"] = config.TELEGRAM_PROXY - os.environ["HTTPS_PROXY"] = config.TELEGRAM_PROXY + client_options["proxy"] = config.TELEGRAM_PROXY - async with httpx.AsyncClient() as client: + async with httpx.AsyncClient(**client_options) as client: res = await client.post( f"https://api.telegram.org/bot{config.TELEGRAM_BOT_TOKEN}/sendMessage", data={"chat_id": config.TELEGRAM_CHAT_ID, "text": msg, "parse_mode": "Markdown"},