🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix: custom base path nullable (#3353)
Marc Klingen23ab79ba4289
diff --git a/web/src/components/LangfuseLogo.tsx b/web/src/components/LangfuseLogo.tsxindex e4c6f6a2d9..c2e146b7c8 100644--- a/web/src/components/LangfuseLogo.tsx+++ b/web/src/components/LangfuseLogo.tsx@@ -13,7 +13,7 @@ export const LangfuseIcon = ({}) => (// eslint-disable-next-line @next/next/no-img-element<img- src={`${env.NEXT_PUBLIC_BASE_PATH}/icon.svg`}+ src={`${env.NEXT_PUBLIC_BASE_PATH ?? ""}/icon.svg`}width={size}height={size}alt="Langfuse Icon"diff --git a/web/src/ee/features/playground/page/context/index.tsx b/web/src/ee/features/playground/page/context/index.tsxindex b378c5c568..5bf2c6da30 100644--- a/web/src/ee/features/playground/page/context/index.tsx+++ b/web/src/ee/features/playground/page/context/index.tsx@@ -272,7 +272,7 @@ async function* getChatCompletionStream(modelParams: getFinalModelParams(modelParams),});const result = await fetch(- `${env.NEXT_PUBLIC_BASE_PATH}/api/chatCompletion`,+ `${env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/chatCompletion`,{method: "POST",headers: { "Content-Type": "application/json" },diff --git a/web/src/env.mjs b/web/src/env.mjsindex d0d4afdac9..ebd03ebfbd 100644--- a/web/src/env.mjs+++ b/web/src/env.mjs@@ -204,7 +204,7 @@ export const env = createEnv({NEXT_PUBLIC_POSTHOG_HOST: z.string().optional(),NEXT_PUBLIC_CRISP_WEBSITE_ID: z.string().optional(),NEXT_PUBLIC_BUILD_ID: z.string().optional(),- NEXT_PUBLIC_BASE_PATH: z.string().optional().default(""),+ NEXT_PUBLIC_BASE_PATH: z.string().optional(),},/**diff --git a/web/src/features/auth-credentials/components/ResetPasswordButton.tsx b/web/src/features/auth-credentials/components/ResetPasswordButton.tsxindex f85d135fe3..9c16edaca2 100644--- a/web/src/features/auth-credentials/components/ResetPasswordButton.tsx+++ b/web/src/features/auth-credentials/components/ResetPasswordButton.tsx@@ -34,7 +34,7 @@ export function RequestResetPasswordEmailButton({try {const res = await signIn("email", {email: email,- callbackUrl: `${env.NEXT_PUBLIC_BASE_PATH}/auth/reset-password`,+ callbackUrl: `${env.NEXT_PUBLIC_BASE_PATH ?? ""}/auth/reset-password`,redirect: false,});if (res?.error) {diff --git a/web/src/features/projects/components/HostNameProject.tsx b/web/src/features/projects/components/HostNameProject.tsxindex ab16813791..c1850b4612 100644--- a/web/src/features/projects/components/HostNameProject.tsx+++ b/web/src/features/projects/components/HostNameProject.tsx@@ -15,7 +15,7 @@ export function HostNameProject() {When connecting to Langfuse, use this hostname / baseurl.</div><CodeView- content={`${uiCustomization?.hostname ?? window.origin}${env.NEXT_PUBLIC_BASE_PATH}`}+ content={`${uiCustomization?.hostname ?? window.origin}${env.NEXT_PUBLIC_BASE_PATH ?? ""}`}/></div></Card>diff --git a/web/src/features/public-api/components/CreateApiKeyButton.tsx b/web/src/features/public-api/components/CreateApiKeyButton.tsxindex 08d53d4a83..e59a96ee27 100644--- a/web/src/features/public-api/components/CreateApiKeyButton.tsx+++ b/web/src/features/public-api/components/CreateApiKeyButton.tsx@@ -110,7 +110,7 @@ export const ApiKeyRender = ({<div><div className="text-md mb-2 font-semibold">Host</div><CodeView- content={`${uiCustomization?.hostname ?? window.origin}${env.NEXT_PUBLIC_BASE_PATH}`}+ content={`${uiCustomization?.hostname ?? window.origin}${env.NEXT_PUBLIC_BASE_PATH ?? ""}`}/></div></>diff --git a/web/src/features/public-api/components/QuickstartExamples.tsx b/web/src/features/public-api/components/QuickstartExamples.tsxindex 0256445095..34dfb8b69f 100644--- a/web/src/features/public-api/components/QuickstartExamples.tsx+++ b/web/src/features/public-api/components/QuickstartExamples.tsx@@ -28,7 +28,7 @@ export const QuickstartExamples = ({{ value: "llamaindex", label: "LlamaIndex" },{ value: "other", label: "Other" },];- const host = `${uiCustomization?.hostname ?? window.origin}${env.NEXT_PUBLIC_BASE_PATH}`;+ const host = `${uiCustomization?.hostname ?? window.origin}${env.NEXT_PUBLIC_BASE_PATH ?? ""}`;// if custom docs link, do not show quickstart examples but refer to docsif (uiCustomization?.documentationHref) {diff --git a/web/src/pages/_app.tsx b/web/src/pages/_app.tsxindex 1b3ae8d0f2..925eba631e 100644--- a/web/src/pages/_app.tsx+++ b/web/src/pages/_app.tsx@@ -96,11 +96,7 @@ const MyApp: AppType<{ session: Session | null }> = ({session={session}refetchOnWindowFocus={true}refetchInterval={5 * 60} // 5 minutes- basePath={- env.NEXT_PUBLIC_BASE_PATH- ? `${env.NEXT_PUBLIC_BASE_PATH}/api/auth`- : undefined- }+ basePath={`${env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/auth`}><DetailPageListsProvider><MarkdownContextProvider>diff --git a/web/src/pages/auth/sign-in.tsx b/web/src/pages/auth/sign-in.tsxindex 266b9db733..69c8edf86b 100644--- a/web/src/pages/auth/sign-in.tsx+++ b/web/src/pages/auth/sign-in.tsx@@ -320,11 +320,14 @@ export default function SignIn({ authProviders, signUpDisabled }: PageProps) {}// current email domainconst domain = email.data.split("@")[1]?.toLowerCase();- const res = await fetch(`${env.NEXT_PUBLIC_BASE_PATH}/api/auth/check-sso`, {- method: "POST",- headers: { "Content-Type": "application/json" },- body: JSON.stringify({ domain }),- });+ const res = await fetch(+ `${env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/auth/check-sso`,+ {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({ domain }),+ },+ );if (!res.ok) {setCredentialsFormError("SSO is not enabled for this domain.");diff --git a/web/src/pages/auth/sign-up.tsx b/web/src/pages/auth/sign-up.tsxindex 249a499923..e94dd42608 100644--- a/web/src/pages/auth/sign-up.tsx+++ b/web/src/pages/auth/sign-up.tsx@@ -48,11 +48,14 @@ export default function SignIn({ authProviders }: PageProps) {async function onSubmit(values: z.infer<typeof signupSchema>) {try {setFormError(null);- const res = await fetch(`${env.NEXT_PUBLIC_BASE_PATH}/api/auth/signup`, {- method: "POST",- headers: { "Content-Type": "application/json" },- body: JSON.stringify(values),- });+ const res = await fetch(+ `${env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/auth/signup`,+ {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify(values),+ },+ );if (!res.ok) {const payload = (await res.json()) as { message: string };diff --git a/web/src/server/auth.ts b/web/src/server/auth.tsindex 95dad875f0..c20f140c4f 100644--- a/web/src/server/auth.ts+++ b/web/src/server/auth.ts@@ -477,11 +477,11 @@ export async function getAuthOptions(): Promise<NextAuthOptions> {adapter: extendedPrismaAdapter,providers,pages: {- signIn: `${env.NEXT_PUBLIC_BASE_PATH}/auth/sign-in`,- error: `${env.NEXT_PUBLIC_BASE_PATH}/auth/error`,+ signIn: `${env.NEXT_PUBLIC_BASE_PATH ?? ""}/auth/sign-in`,+ error: `${env.NEXT_PUBLIC_BASE_PATH ?? ""}/auth/error`,...(env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION? {- newUser: `${env.NEXT_PUBLIC_BASE_PATH}/onboarding`,+ newUser: `${env.NEXT_PUBLIC_BASE_PATH ?? ""}/onboarding`,}: {}),},diff --git a/web/src/utils/api.ts b/web/src/utils/api.tsindex 6563b5bc00..2cd7dcd587 100644--- a/web/src/utils/api.ts+++ b/web/src/utils/api.ts@@ -35,7 +35,7 @@ const getBaseUrl = () => {? `https://${process.env.VERCEL_URL}`: `http://localhost:${process.env.PORT ?? 3000}`;- return `${hostname}${env.NEXT_PUBLIC_BASE_PATH}`;+ return `${hostname}${env.NEXT_PUBLIC_BASE_PATH ?? ""}`;};// global build id used to compare versions to show refresh toast on stale cache hit serving deprecated files