返回提交历史
Modified
g4f/api/__init__.py
+4
-0
XFEstudio/gpt4free
Log requests
ba1f9bb3
代码差异
1 个文件
+4
-0
@@ -261,6 +261,10 @@ class Api:
261
261
if path.startswith("/v1") or path.startswith("/api/") or (AppConfig.demo and path == '/backend-api/v2/upload_cookies'):
262
262
if request.method != "OPTIONS":
263
263
if user_g4f_api_key is None:
264
ip = request.headers.get("X-Forwarded-For", "")[:4].strip(":.")
265
country = request.headers.get("Cf-Ipcountry", "")
266
agent = request.headers.get("User-Agent", "")
267
debug.log(f"User: '{user}' G4F API key is required. IP: {ip}, Country: {country}, User-Agent: {agent}")
264
268
return ErrorResponse.from_message("G4F API key required", HTTP_401_UNAUTHORIZED)
265
269
if AppConfig.g4f_api_key is None and user is None:
266
270
return ErrorResponse.from_message("Invalid G4F API key", HTTP_403_FORBIDDEN)