callbackUrl seems to be ignored
See original GitHub issueDescribe the bug
Using callbackUrl with email, google, and twitter providers. I would expect the application to redirect to this URL after successful sign-in. Instead, it always redirects to the root.
Steps to reproduce
const { error: signInError } = await signIn('email', {
callbackUrl,
email,
redirect: false,
});
…where callbackUrl is currently hardcoded to http://localhost:3000/picks/set
. I have confirmed this value, however, there is a cookie I see with the name next-auth.callback-url
that is always set to http%3A%2F%2Flocalhost%3A3000
.
Expected behavior
I would expect the application to be redirected to http://localhost:3000/picks/set after successful authentication.
Screenshots or error logs
N/A
Additional context
I am using the latest NextAuth (3.13.0) and NextJS (10.0.9). Node version is 14.15.4.
Feedback Documentation refers to searching through online documentation, code comments and issue history. The example project refers to next-auth-example.
- Found the documentation helpful
- Found documentation but was incomplete
- Could not find relevant documentation
- Found the example project helpful
- Did not find the example project helpful
Issue Analytics
- State:
- Created 3 years ago
- Reactions:17
- Comments:10 (1 by maintainers)
There’s a solution while this bug isn’t fixed.
$ yarn add cookies
Then on your page:
import Cookies from 'cookies'
add this to
getServerSideProps(context)
:thanks for pointing out to
next-auth.callback-url
I have found a workaround fix (tested locally and production) for this issue by doing the following:
in
[...nextauth.ts]
add a custom login page:in
[...nextauth.ts]
add the following undercallbacks
:in custom login page (e.g
login.tsx
) :in any page (e.g:
index.tsx
) :