fix: fix where go2rtc functionality becomes unavailable after setting the HTTP_PROXY environment variable.

This commit is contained in:
ZhaiSoul 2026-02-05 15:38:30 +00:00
parent c9ba851f0d
commit bf0d985b9d
2 changed files with 12 additions and 3 deletions

View File

@ -56,7 +56,9 @@ def _is_valid_host(host: str) -> bool:
@router.get("/go2rtc/streams", dependencies=[Depends(allow_any_authenticated())]) @router.get("/go2rtc/streams", dependencies=[Depends(allow_any_authenticated())])
def go2rtc_streams(): def go2rtc_streams():
r = requests.get("http://127.0.0.1:1984/api/streams") r = requests.get(
"http://127.0.0.1:1984/api/streams", proxies={"http": None, "https": None}
)
if not r.ok: if not r.ok:
logger.error("Failed to fetch streams from go2rtc") logger.error("Failed to fetch streams from go2rtc")
return JSONResponse( return JSONResponse(
@ -75,7 +77,8 @@ def go2rtc_streams():
) )
def go2rtc_camera_stream(request: Request, camera_name: str): def go2rtc_camera_stream(request: Request, camera_name: str):
r = requests.get( r = requests.get(
f"http://127.0.0.1:1984/api/streams?src={camera_name}&video=all&audio=all&microphone" f"http://127.0.0.1:1984/api/streams?src={camera_name}&video=all&audio=all&microphone",
proxies={"http": None, "https": None},
) )
if not r.ok: if not r.ok:
camera_config = request.app.frigate_config.cameras.get(camera_name) camera_config = request.app.frigate_config.cameras.get(camera_name)
@ -107,6 +110,7 @@ def go2rtc_add_stream(request: Request, stream_name: str, src: str = ""):
"http://127.0.0.1:1984/api/streams", "http://127.0.0.1:1984/api/streams",
params=params, params=params,
timeout=10, timeout=10,
proxies={"http": None, "https": None},
) )
if not r.ok: if not r.ok:
logger.error(f"Failed to add go2rtc stream {stream_name}: {r.text}") logger.error(f"Failed to add go2rtc stream {stream_name}: {r.text}")
@ -142,6 +146,7 @@ def go2rtc_delete_stream(stream_name: str):
"http://127.0.0.1:1984/api/streams", "http://127.0.0.1:1984/api/streams",
params={"src": stream_name}, params={"src": stream_name},
timeout=10, timeout=10,
proxies={"http": None, "https": None},
) )
if not r.ok: if not r.ok:
logger.error(f"Failed to delete go2rtc stream {stream_name}: {r.text}") logger.error(f"Failed to delete go2rtc stream {stream_name}: {r.text}")

View File

@ -629,7 +629,11 @@ def auto_detect_hwaccel() -> str:
try: try:
cuda = False cuda = False
vaapi = False vaapi = False
resp = requests.get("http://127.0.0.1:1984/api/ffmpeg/hardware", timeout=3) resp = requests.get(
"http://127.0.0.1:1984/api/ffmpeg/hardware",
timeout=3,
proxies={"http": None, "https": None},
)
if resp.status_code == 200: if resp.status_code == 200:
data: dict[str, list[dict[str, str]]] = resp.json() data: dict[str, list[dict[str, str]]] = resp.json()