The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(e2e/ui): resolve dashboard base URL from env instead of hardcoding localhost (#34739)
mubashir1osmani612eb614d0d8
diff --git a/tests/e2e/ui/constants.ts b/tests/e2e/ui/constants.tsindex 236909384b0..17adb0f5fce 100644--- a/tests/e2e/ui/constants.ts+++ b/tests/e2e/ui/constants.ts@@ -1,3 +1,9 @@+export const UI_BASE_URL = (+ process.env.E2E_UI_BASE_URL ||+ process.env.LITELLM_PROXY_URL ||+ "http://localhost:4000"+).replace(/\/+$/, "");+// Storage state paths for each roleexport const ADMIN_STORAGE_PATH = "admin.storageState.json";export const ADMIN_VIEWER_STORAGE_PATH = "adminViewer.storageState.json";diff --git a/tests/e2e/ui/globalSetup.ts b/tests/e2e/ui/globalSetup.tsindex ef892870268..6dae603b7cf 100644--- a/tests/e2e/ui/globalSetup.ts+++ b/tests/e2e/ui/globalSetup.ts@@ -1,5 +1,6 @@import { chromium, expect, request } from "@playwright/test";import { users, Role, STORAGE_PATHS } from "./fixtures/users";+import { UI_BASE_URL } from "./constants";import * as fs from "fs";async function globalSetup() {@@ -12,7 +13,7 @@ async function globalSetup() {// the admin UI toggle does; the projects migration smoke needs the link.const masterKey = process.env.LITELLM_MASTER_KEY || "sk-1234";const api = await request.newContext();- const settingsRes = await api.patch(`http://localhost:4000${rootPath}/update/ui_settings`, {+ const settingsRes = await api.patch(`${UI_BASE_URL}${rootPath}/update/ui_settings`, {headers: { Authorization: `Bearer ${masterKey}` },data: { enable_projects_ui: true },});@@ -26,7 +27,7 @@ async function globalSetup() {const storagePath = STORAGE_PATHS[role];const page = await browser.newPage();try {- await page.goto(`http://localhost:4000${rootPath}/ui/login`);+ await page.goto(`${UI_BASE_URL}${rootPath}/ui/login`);await page.getByPlaceholder("Enter your username").fill(email);await page.getByPlaceholder("Enter your password").fill(password);await page.getByRole("button", { name: "Login", exact: true }).click();diff --git a/tests/e2e/ui/migration.serverRootPath.config.ts b/tests/e2e/ui/migration.serverRootPath.config.tsindex d32f59b16bf..dc83f3d6584 100644--- a/tests/e2e/ui/migration.serverRootPath.config.ts+++ b/tests/e2e/ui/migration.serverRootPath.config.ts@@ -1,4 +1,5 @@import { defineConfig, devices } from "@playwright/test";+import { UI_BASE_URL } from "./constants";/*** App Router migration smoke under a non-root mount. Boot the proxy with the same@@ -15,7 +16,7 @@ export default defineConfig({workers: process.env.CI ? 1 : undefined,reporter: "list",use: {- baseURL: "http://localhost:4000",+ baseURL: UI_BASE_URL,trace: "on-first-retry",actionTimeout: 15 * 1000,navigationTimeout: 30 * 1000,diff --git a/tests/e2e/ui/playwright.config.ts b/tests/e2e/ui/playwright.config.tsindex 8d586ce9503..8ae8ddad639 100644--- a/tests/e2e/ui/playwright.config.ts+++ b/tests/e2e/ui/playwright.config.ts@@ -1,4 +1,5 @@import { defineConfig, devices } from "@playwright/test";+import { UI_BASE_URL } from "./constants";/*** See https://playwright.dev/docs/test-configuration.@@ -20,7 +21,7 @@ export default defineConfig({/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */use: {/* Base URL to use in actions like `await page.goto('/')`. */- baseURL: "http://localhost:4000",+ baseURL: UI_BASE_URL,/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */trace: "on-first-retry",diff --git a/tests/e2e/ui/tests/auth/unauthenticatedRedirect.spec.ts b/tests/e2e/ui/tests/auth/unauthenticatedRedirect.spec.tsindex 4c6e11800ee..3c2a3c2103e 100644--- a/tests/e2e/ui/tests/auth/unauthenticatedRedirect.spec.ts+++ b/tests/e2e/ui/tests/auth/unauthenticatedRedirect.spec.ts@@ -2,7 +2,7 @@ import { test, expect } from "@playwright/test";test.describe("Authentication Checks", () => {test("should redirect unauthenticated user from a protected page", async ({ page }) => {- const protectedPageUrl = "http://localhost:4000/ui?page=llm-playground";+ const protectedPageUrl = "/ui?page=llm-playground";await page.goto(protectedPageUrl, { waitUntil: "domcontentloaded" });await expect(page).toHaveURL(/\/ui\/login/);await expect(page.getByRole("heading", { name: "Login" })).toBeVisible();diff --git a/tests/e2e/ui/tests/login/login.spec.ts b/tests/e2e/ui/tests/login/login.spec.tsindex 88378df36c3..68cae4ebcc5 100644--- a/tests/e2e/ui/tests/login/login.spec.ts+++ b/tests/e2e/ui/tests/login/login.spec.ts@@ -3,7 +3,7 @@ import { users } from "../../fixtures/users";import { Role } from "../../fixtures/roles";test("user can log in", async ({ page }) => {- await page.goto("http://localhost:4000/ui/login");+ await page.goto("/ui/login");await page.getByPlaceholder("Enter your username").fill(users[Role.ProxyAdmin].email);await page.getByPlaceholder("Enter your password").fill(users[Role.ProxyAdmin].password);const loginButton = page.getByRole("button", { name: "Login", exact: true });diff --git a/tests/e2e/ui/tests/proxy-admin/teams.spec.ts b/tests/e2e/ui/tests/proxy-admin/teams.spec.tsindex e7f67d7367f..17ff62f37cf 100644--- a/tests/e2e/ui/tests/proxy-admin/teams.spec.ts+++ b/tests/e2e/ui/tests/proxy-admin/teams.spec.ts@@ -132,7 +132,7 @@ test.describe("Proxy Admin - Teams", () => {const masterKey = process.env.LITELLM_MASTER_KEY || "sk-1234";const seededModels = ["fake-openai-gpt-4", "fake-anthropic-claude"];const restore = async () => {- const res = await request.post("http://localhost:4000/team/update", {+ const res = await request.post("/team/update", {headers: { Authorization: `Bearer ${masterKey}` },data: { team_id: E2E_TEAM_CRUD_ID, models: seededModels },});diff --git a/tests/e2e/ui/tests/settings/routerSettings.spec.ts b/tests/e2e/ui/tests/settings/routerSettings.spec.tsindex ffa5f2c2ae2..631d2814664 100644--- a/tests/e2e/ui/tests/settings/routerSettings.spec.ts+++ b/tests/e2e/ui/tests/settings/routerSettings.spec.ts@@ -23,7 +23,7 @@ async function clearFallbackForPrimary(request: import("@playwright/test").APIReconst masterKey = users[Role.ProxyAdmin].password;const auth = { Authorization: `Bearer ${masterKey}` };- const current = await request.get("http://localhost:4000/get/config/callbacks", { headers: auth });+ const current = await request.get("/get/config/callbacks", { headers: auth });if (!current.ok()) return;const body = await current.json();const router = body?.router_settings ?? {};@@ -31,7 +31,7 @@ async function clearFallbackForPrimary(request: import("@playwright/test").APIReconst next = existing.filter((entry) => !(entry && PRIMARY in entry));if (next.length === existing.length) return;- await request.post("http://localhost:4000/config/update", {+ await request.post("/config/update", {headers: auth,data: { router_settings: { ...router, fallbacks: next } },});@@ -111,7 +111,6 @@ test.describe("Router Settings - Fallbacks", () => {type ConfigYAML = components["schemas"]["ConfigYAML"];type RouterSettingsResponse = components["schemas"]["RouterSettingsResponse"];-const BASE_URL = "http://localhost:4000";const ADMIN_AUTH = { Authorization: `Bearer ${users[Role.ProxyAdmin].password}` };/**@@ -123,7 +122,7 @@ async function patchRouterSettings(request: import("@playwright/test").APIRequestContext,patch: Partial<NonNullable<ConfigYAML["router_settings"]>>,) {- const res = await request.post(`${BASE_URL}/config/update`, {+ const res = await request.post(`/config/update`, {headers: ADMIN_AUTH,data: { router_settings: patch },});@@ -179,7 +178,7 @@ test.describe("Router Settings - Loadbalancing", () => {await expect.poll(async () => {- const res = await request.get(`${BASE_URL}/router/settings`, { headers: ADMIN_AUTH });+ const res = await request.get(`/router/settings`, { headers: ADMIN_AUTH });const data = (await res.json()) as RouterSettingsResponse;return data.current_values?.num_retries;},