Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

small middleware fix

Steven Tey0efaafb58c7e
diff --git a/lib/middleware/app.ts b/lib/middleware/app.ts
index 8194e5ab1b..6a4383e827 100644
--- a/lib/middleware/app.ts
+++ b/lib/middleware/app.ts
@@ -16,7 +16,7 @@ export default async function AppMiddleware(req: NextRequest) {
if (!session?.email && path !== "/login" && path !== "/register") {
return NextResponse.redirect(
new URL(
- `/login?next=${encodeURIComponent(new URL(req.url).pathname)}`,
+ `/login${path !== "/" ? `?next=${encodeURIComponent(path)}` : ""}`,
req.url,
),
);