🔍️ Only set callback url if not root (#1521)

This commit is contained in:
Luke Vella 2025-01-27 20:03:46 +00:00 committed by GitHub
parent 4907576a3e
commit c7e4fcb4ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -39,7 +39,9 @@ export const middleware = withAuth(
!isLoggedIn &&
!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";
return NextResponse.redirect(newUrl);
}