🔍️ Only set callback url if not root

This commit is contained in:
Luke Vella 2025-01-27 19:58:47 +00:00
parent af6f7b6140
commit a39f64eab9
No known key found for this signature in database
GPG key ID: 469CAD687F0D784C

View file

@ -39,7 +39,9 @@ export const middleware = withAuth(
!isLoggedIn && !isLoggedIn &&
!publicRoutes.some((route) => newUrl.pathname.startsWith(route)) !publicRoutes.some((route) => newUrl.pathname.startsWith(route))
) { ) {
newUrl.searchParams.set("callbackUrl", newUrl.pathname); if (newUrl.pathname !== "/") {
newUrl.searchParams.set("callbackUrl", newUrl.pathname);
}
newUrl.pathname = "/login"; newUrl.pathname = "/login";
return NextResponse.redirect(newUrl); return NextResponse.redirect(newUrl);
} }