返回提交历史
Modified
g4f/api/__init__.py
+3
-3
XFEstudio/gpt4free
Fix API key requirement path checks in Api class
4bf0828a
代码差异
1 个文件
+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")