api: support to config disabling Swagger UI in api service (#24440)

This commit is contained in:
Bowen Liang
2025-08-26 15:48:04 +08:00
committed by GitHub
parent 47f480c0dc
commit 6e674b511a
6 changed files with 34 additions and 5 deletions

View File

@@ -21,7 +21,7 @@ login_manager = flask_login.LoginManager()
def load_user_from_request(request_from_flask_login):
"""Load user based on the request."""
# Skip authentication for documentation endpoints
if request.path.endswith("/docs") or request.path.endswith("/swagger.json"):
if dify_config.SWAGGER_UI_ENABLED and request.path.endswith((dify_config.SWAGGER_UI_PATH, "/swagger.json")):
return None
auth_header = request.headers.get("Authorization", "")