返回提交历史
Modified
g4f/api/__init__.py
+5
-4
XFEstudio/gpt4free
Fix cors
89a45f38
代码差异
1 个文件
+5
-4
@@ -257,10 +257,11 @@ class Api:
257
257
user = "admin"
258
258
path = request.url.path
259
259
if path.startswith("/v1") or path.startswith("/api/") or (AppConfig.demo and path == '/backend-api/v2/upload_cookies'):
260
if user_g4f_api_key is None:
261
return ErrorResponse.from_message("G4F API key required", HTTP_401_UNAUTHORIZED)
262
if AppConfig.g4f_api_key is None and user is None:
263
return ErrorResponse.from_message("Invalid G4F API key", HTTP_403_FORBIDDEN)
260
if request.method != "OPTIONS":
261
if user_g4f_api_key is None:
262
return ErrorResponse.from_message("G4F API key required", HTTP_401_UNAUTHORIZED)
263
if AppConfig.g4f_api_key is None and user is None:
264
return ErrorResponse.from_message("Invalid G4F API key", HTTP_403_FORBIDDEN)
264
265
elif not AppConfig.demo and not path.startswith("/images/") and not path.startswith("/media/"):
265
266
if user_g4f_api_key is not None:
266
267
if user is None: