Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(web): show the staging AI gateway host on staging (#18922)

Tobias Wochinger74ba59ec5e46
diff --git a/web/src/__tests__/server/ai-gateway-control-plane.servertest.ts b/web/src/__tests__/server/ai-gateway-control-plane.servertest.ts
index d5c78cb0b2..b021644371 100644
--- a/web/src/__tests__/server/ai-gateway-control-plane.servertest.ts
+++ b/web/src/__tests__/server/ai-gateway-control-plane.servertest.ts
@@ -225,7 +225,7 @@ describe("AI gateway control plane", () => {
it.each([
{
productUrl: "https://staging.langfuse.com",
- gatewayUrl: "https://gateway.staging.langfuse.com/v1",
+ gatewayUrl: "https://staging.langfuse.com",
},
{
productUrl: "http://localhost:3000",
diff --git a/web/src/features/ai-gateway/fns/gatewayUrls/getGatewayBaseUrl.clienttest.ts b/web/src/features/ai-gateway/fns/gatewayUrls/getGatewayBaseUrl.clienttest.ts
index 7997307596..826aa71aca 100644
--- a/web/src/features/ai-gateway/fns/gatewayUrls/getGatewayBaseUrl.clienttest.ts
+++ b/web/src/features/ai-gateway/fns/gatewayUrls/getGatewayBaseUrl.clienttest.ts
@@ -5,9 +5,15 @@ import { describe, expect, it } from "vitest";
import { getGatewayBaseUrl } from "@/src/features/ai-gateway/fns/gatewayUrls/getGatewayBaseUrl";
describe("getGatewayBaseUrl", () => {
- it("prefixes gateway. onto a product host", () => {
+ it("returns the staging product host that serves the gateway", () => {
expect(getGatewayBaseUrl(new URL("https://staging.langfuse.com/"))).toBe(
- "https://gateway.staging.langfuse.com/v1",
+ "https://staging.langfuse.com",
+ );
+ });
+
+ it("prefixes gateway. onto a product host", () => {
+ expect(getGatewayBaseUrl(new URL("https://cloud.langfuse.com/"))).toBe(
+ "https://gateway.cloud.langfuse.com/v1",
);
});
diff --git a/web/src/features/ai-gateway/fns/gatewayUrls/getGatewayBaseUrl.ts b/web/src/features/ai-gateway/fns/gatewayUrls/getGatewayBaseUrl.ts
index fe6d4739b9..4dba92f1bc 100644
--- a/web/src/features/ai-gateway/fns/gatewayUrls/getGatewayBaseUrl.ts
+++ b/web/src/features/ai-gateway/fns/gatewayUrls/getGatewayBaseUrl.ts
@@ -3,7 +3,14 @@ const LOCAL_GATEWAY_HOSTS = new Set(["localhost", "127.0.0.1", "[::1]"]);
/** Matches numbered preview hosts that use the certificate-covered gateway hostname. */
const PREVIEW_HOST = /^pr-(\d+)\.preview\.langfuse\.com$/;
+/** Staging serves the gateway on the product host under `/openai/v1` and `/anthropic`. */
+const STAGING_ORIGIN = "https://staging.langfuse.com";
+
export function getGatewayBaseUrl(productBaseUrl: URL) {
+ if (productBaseUrl.origin === STAGING_ORIGIN) {
+ return STAGING_ORIGIN;
+ }
+
const gatewayBaseUrl = new URL(productBaseUrl);
if (LOCAL_GATEWAY_HOSTS.has(gatewayBaseUrl.hostname)) {