XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/gpt4free

Fix API key requirement path checks in Api class

4bf0828a
hlohaus <983577+hlohaus@users.noreply.github.com>
提交于

代码差异

1 个文件 +3 -3
Modified g4f/api/__init__.py +3 -3
@@ -100,7 +100,7 @@ logger = logging.getLogger(__name__)
100 100 # Request / response log store
101 101 # ---------------------------------------------------------------------------
102 102
103 _MAX_LOG_ENTRIES = 1000
103 _MAX_LOG_ENTRIES = 250
104 104 _MAX_BODY_LOG_SIZE = 1024 * 1024 # 1 MB
105 105 _SENSITIVE_HEADERS = {"authorization", "g4f-api-key", "cookie", "set-cookie", "x-api-key"}
106 106
@@ -477,10 +477,10 @@ class Api:
477 477 def _requires_api_key(path: str, demo: bool) -> bool:
478 478 """Return ``True`` when *path* must present a G4F API key."""
479 479 return (
480 path.startswith("/v1")
480 path.startswith("/v1/")
481 481 or path.startswith("/api/")
482 482 or (path.startswith("/pa/") and not demo)
483 or (demo and path == "/backend-api/v2/upload_cookies")
483 or (demo and path in ["/backend-api/v2/upload_cookies", "/logs", "/api/logs"])
484 484 )
485 485
486 486 @self.app.middleware("http")