Weird behaviour when logging in with Discord
Hey, I am using Better Auth with latest Next.js and I have this weird "bug (?)" when logging in with Discord. Discord is my only option to log in with.
When I click the login button, which I have tried two approaches:
1. Client component with a button that has an async
onClick()
event which awaits the signIn()
function from auth-client.ts
.
2. Same as the first one, but with a server action instead.
The button looks like this:
The signIn()
function looks like this:
When I start my local server and click the login button, I get an error, however without any message. This is the output in the dev tools console after I click it:
What's weird is that the button starts to work after I modify either the onSuccess()
or onError()
function, just another console.log()
is enough. Then it starts to work again.
I have built the authentication using the documentation and all of the code for auth comes from there too.
Does anyone know what the issue could be?3 Replies
Did you manage to fix the issue? Having the same problem
I didn't, but seems like the new version (1.2.1) fixed the issue
i can confirm that this is still an issue with 1.2.3
Click login button -> initiates Discord auth
2. Discord authenticates successfully and calls back
3. Instead of redirecting to /dashboard (as configured in redirects.afterSignIn), it redirects to /