set PROXY_BASE_URL when server root path set

This commit is contained in:
Ishaan Jaff 2024-08-05 15:48:44 -07:00
parent 81c2c919e1
commit e6f4d7a81d

View file

@ -281,9 +281,12 @@ except Exception as e:
except Exception as e:
pass
server_root_path = os.getenv("SERVER_ROOT_PATH", "")
if server_root_path != "" and os.getenv("PROXY_BASE_URL") is None:
os.environ["PROXY_BASE_URL"] = server_root_path
_license_check = LicenseCheck()
premium_user: bool = _license_check.is_premium()
ui_link = f"/ui/"
ui_link = f"{server_root_path}/ui/"
ui_message = (
f"👉 [```LiteLLM Admin Panel on /ui```]({ui_link}). Create, Edit Keys with SSO"
)
@ -303,14 +306,13 @@ _description = (
else f"Proxy Server to call 100+ LLMs in the OpenAI format. {custom_swagger_message}\n\n{ui_message}"
)
app = FastAPI(
docs_url=_docs_url,
title=_title,
description=_description,
version=version,
root_path=os.environ.get(
"SERVER_ROOT_PATH", ""
), # check if user passed root path, FastAPI defaults this value to ""
root_path=server_root_path, # check if user passed root path, FastAPI defaults this value to ""
)