Response.redirect navigating to the url but not updating it in the address bar
Im using nextAuth@beta version to implement authentication in my nextjs14 app.
When user got logged in it is routing to the portal screen which is fine but after routing its not changing url in the address bar which is quite a problematic for me. I have search a lot about it but got nothing
`export const authConfig: NextAuthConfig = { pages: { signIn: "/login", }, callbacks: { async jwt({ token, user }) { if (user && user?.accessToken) { token.accessToken = user.accessToken; } return token; }, async session({ session, user, token }) { session.user = { name: session?.user?.name, email: session?.user?.email, image: session?.user?.image, accessToken: token?.accessToken, }; return session; }, authorized({ auth, request: { nextUrl, url } }) { const isLoggedIn = !!auth?.user; const isRootOrDashboard = nextUrl.pathname === "/" || nextUrl.pathname.startsWith("/portal");
if (isRootOrDashboard) {
if (!isLoggedIn) {
return false
} else if (nextUrl.pathname === "/") {
return Response.redirect(new URL("/portal", nextUrl));
}
} else if (isLoggedIn) {
return Response.redirect(new URL("/portal", nextUrl));
}
return true;
},
}, providers: [] }; `
Same here, this fails in 14.2 but works in 14.1
Same here, this fails in 14.2 but works in 14.1
Thank you much. It worked
changing the version didn't work for me but eventually I was able to fix it thanks to this comment https://github.com/vercel/next.js/issues/65936#issuecomment-2121071370
~changing the version didn't work for me~ I was able to fix it thanks to this post vercel/next.js#65936 (comment)
was it just a version change that fixed for you are is there something else you have to change? Im running into something similar with have a next redirect inside of auth middleware right now
was it just a version change that fixed for you are is there something else you have to change? Im running into something similar with have a next redirect inside of auth middleware right now
If I remember correctly changing the version did not fix it for me, but following the comment I linked did
changing the version didn't work for me but eventually I was able to fix it thanks to this comment vercel/next.js#65936 (comment)
It worked for me thank you so much
Fixed here https://github.com/vercel/next-learn/pull/983
changing the version didn't work for me but eventually I was able to fix it thanks to this comment vercel/next.js#65936 (comment)
It worked for me thank you so much
can you tell me please, which specific comment you follow ?
changing the version didn't work for me but eventually I was able to fix it thanks to this comment vercel/next.js#65936 (comment)
It worked for me thank you so much
can you tell me please, which specific comment you follow ?
Sorry, I can't really remember right now since a lot of time has passed, but it was probably adding the "redirectTo" in the signIn param object
changing the version didn't work for me but eventually I was able to fix it thanks to this comment vercel/next.js#65936 (comment)
It worked for me thank you so much
can you tell me please, which specific comment you follow ?
Sorry, I can't really remember right now since a lot of time has passed, but it was probably adding the "redirectTo" in the signIn param object
can we connect in discord ?