mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-05 02:41:56 +00:00
fix(proxy): block /ui/* static routes when DISABLE_ADMIN_UI=true
This commit is contained in:
parent
740bb44796
commit
203f493596
1 changed files with 14 additions and 1 deletions
|
|
@ -302,6 +302,7 @@ from litellm.proxy.common_utils.encrypt_decrypt_utils import (
|
|||
decrypt_value_helper,
|
||||
encrypt_value_helper,
|
||||
)
|
||||
from litellm.proxy.common_utils.admin_ui_utils import admin_ui_disabled
|
||||
from litellm.proxy.common_utils.html_forms.ui_login import build_ui_login_form
|
||||
from litellm.proxy.common_utils.http_parsing_utils import (
|
||||
_read_request_body,
|
||||
|
|
@ -1454,7 +1455,19 @@ try:
|
|||
)
|
||||
# print(f"mounted _next at {server_root_path}/ui/_next")
|
||||
|
||||
app.mount("/ui", StaticFiles(directory=ui_path, html=True), name="ui")
|
||||
_disable_admin_ui = str_to_bool(os.getenv("DISABLE_ADMIN_UI", "false")) is True
|
||||
if _disable_admin_ui:
|
||||
|
||||
@app.get("/ui/{path:path}")
|
||||
async def ui_disabled_path(path: str):
|
||||
return admin_ui_disabled()
|
||||
|
||||
@app.get("/ui")
|
||||
async def ui_disabled_root():
|
||||
return admin_ui_disabled()
|
||||
|
||||
else:
|
||||
app.mount("/ui", StaticFiles(directory=ui_path, html=True), name="ui")
|
||||
|
||||
def _restructure_ui_html_files(ui_root: str) -> None:
|
||||
"""Ensure each exported HTML route is available as <route>/index.html."""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue