Skip to content

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

fix: new users should see /onboarding (#11038)

Marc Klingen389dedb15a1b
diff --git a/web/src/components/error-page.tsx b/web/src/components/error-page.tsx
index f7ad099faf..577d695f92 100644
--- a/web/src/components/error-page.tsx
+++ b/web/src/components/error-page.tsx
@@ -27,6 +27,11 @@ export const ErrorPage = ({
const session = useSession();
const router = useRouter();
const newTargetPath = stripBasePath(router.asPath || "/");
+ // Only include targetPath if it's not the root (since "/" is the default anyway)
+ const targetPathQuery =
+ newTargetPath !== "/"
+ ? `?targetPath=${encodeURIComponent(newTargetPath)}`
+ : "";
return (
<div className="flex h-full flex-col items-center justify-center">
@@ -36,11 +41,7 @@ export const ErrorPage = ({
<div className="flex gap-3">
{session.status === "unauthenticated" ? (
<Button
- onClick={() =>
- void router.push(
- `/auth/sign-in?targetPath=${encodeURIComponent(newTargetPath)}`,
- )
- }
+ onClick={() => void router.push(`/auth/sign-in${targetPathQuery}`)}
>
Sign In
</Button>
diff --git a/web/src/components/layouts/app-layout/hooks/useAuthGuard.ts b/web/src/components/layouts/app-layout/hooks/useAuthGuard.ts
index f21331406c..17ab64b274 100644
--- a/web/src/components/layouts/app-layout/hooks/useAuthGuard.ts
+++ b/web/src/components/layouts/app-layout/hooks/useAuthGuard.ts
@@ -91,10 +91,16 @@ export function useAuthGuard(
// Strip the base path if present to avoid double-prepending
const rawPath = asPath || pathname || "/";
const pathToStore = stripBasePath(rawPath);
- const targetPath = encodeURIComponent(pathToStore);
+
+ // Only include targetPath if it's not the root
+ const targetPathQuery =
+ pathToStore !== "/"
+ ? `?targetPath=${encodeURIComponent(pathToStore)}`
+ : "";
+
return {
action: "redirect",
- url: `/auth/sign-in?targetPath=${targetPath}`,
+ url: `/auth/sign-in${targetPathQuery}`,
message: "Redirecting",
};
}
diff --git a/web/src/components/layouts/app-layout/index.tsx b/web/src/components/layouts/app-layout/index.tsx
index 7da419357d..068888de53 100644
--- a/web/src/components/layouts/app-layout/index.tsx
+++ b/web/src/components/layouts/app-layout/index.tsx
@@ -28,7 +28,6 @@ import { useAuthGuard } from "./hooks/useAuthGuard";
import { useProjectAccess } from "./hooks/useProjectAccess";
import { useFilteredNavigation } from "./hooks/useFilteredNavigation";
import { useLayoutMetadata } from "./hooks/useLayoutMetadata";
-import { stripBasePath } from "@/src/utils/redirect";
/**
* Main layout component
@@ -128,11 +127,7 @@ export function AppLayout(props: PropsWithChildren) {
const handleSignOut = async () => {
sessionStorage.clear();
- // Redirect to sign-in with current path as targetPath for post-login redirect
- const pathWithoutBase = stripBasePath(router.asPath || "/");
- const targetPath = encodeURIComponent(pathWithoutBase);
- // explicitly set callbackUrl to avoid error pages when the user is currently on a publishable path without a published entity
- await signOut({ callbackUrl: `/auth/sign-in?targetPath=${targetPath}` });
+ await signOut({ callbackUrl: `/auth/sign-in` });
};
return (