Skip to content

Commit 75602a3

Browse files
bboyz269sa-codymaiThangHuuVu
authoredMay 31, 2022
fix(middleware): use relative URL for sign-in page callbackUrl (#4534)
* Use relative URL for middleware's signin callbackUrl * Include params to callbackUrl if any * For testing purpose, append params to existing link for test instead of create another one * Update apps/dev/components/header.js Co-authored-by: CODY Mai <nhan.mai@shiftasia.com> Co-authored-by: Thang Vu <31528554+ThangHuuVu@users.noreply.github.com>
1 parent 5b8a619 commit 75602a3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

‎packages/next-auth/src/next/middleware.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ async function handleMiddleware(
101101

102102
// the user is not logged in, redirect to the sign-in page
103103
const signInUrl = new URL(signInPage, req.nextUrl.origin)
104-
signInUrl.searchParams.append("callbackUrl", req.url)
104+
signInUrl.searchParams.append("callbackUrl", `${req.nextUrl.pathname}${req.nextUrl.search}`)
105105
return NextResponse.redirect(signInUrl)
106106
}
107107

1 commit comments

Comments
 (1)

thevuong commented on Jun 11, 2022

@thevuong
Contributor

This causes conflicts with the assertConfig method when testing with the isValidHttpUrl method.
This problem occurs when used with middleware in Next.js: default-re-export

Please sign in to comment.