Fail redirect with callbackUrl next-auth
Answered
Kerry Blue Terrier posted this in #help-forum
Kerry Blue TerrierOP
Hello everyone!
My next-auth signIn is redirecting to:
Does anyone know why this callbackUrl is within of the URL and how to solve it?
My next-auth signIn is redirecting to:
http://localhost:3000/?callbackUrl=https%3A%2F%2F127.0.0.1%3A3000%2Fdashboard
.Does anyone know why this callbackUrl is within of the URL and how to solve it?
Answered by B33fb0n3
if you don't use the pre build site from next-auth, you need to handle the callback url yourself. You can get it clientside by using
useSearchParams
and then redirect with the router
to the specific url6 Replies
it's inside the url so your app knows where to redirect the person after a sign in response. It shows where the user comes from to redirect him back after everything is done
Kerry Blue TerrierOP
But it didn't work, url change from
Any suggestions, please?
http://localhost:3000
to http://localhost:3000/?callbackUrl=https%3A%2F%2F127.0.0.1%3A3000%2Fdashboard
but page stay at SignIn Page. Any suggestions, please?
if you don't use the pre build site from next-auth, you need to handle the callback url yourself. You can get it clientside by using
useSearchParams
and then redirect with the router
to the specific urlAnswer
Kerry Blue TerrierOP
It solved my problem, thanks a lot.
Happy to help