Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

middleware: append path & search params on redirect if email update

Ashish Viradiya9421b2459e76
diff --git a/lib/middleware/app.ts b/lib/middleware/app.ts
index 944f9fee..75f5c8b2 100644
--- a/lib/middleware/app.ts
+++ b/lib/middleware/app.ts
@@ -20,7 +20,10 @@ export default async function AppMiddleware(req: NextRequest) {
const loginUrl = new URL(`/login`, req.url);
// Append "next" parameter only if not navigating to the root
if (path !== "/") {
- loginUrl.searchParams.set("next", encodeURIComponent(path));
+ const nextPath =
+ path === "/auth/confirm-email-change" ? `${path}${url.search}` : path;
+
+ loginUrl.searchParams.set("next", encodeURIComponent(nextPath));
}
return NextResponse.redirect(loginUrl);
}