Redirection after sign in

So I have better auth running on my express server. and better auth client on my Nextjs frontend. Express server is running on localhost:4000 and Nextjs on localhost:3000 The issue is after I initiate google login from NextJs (3000 port), the login is successful, however I get redirected to localhost:4000 as in the server URL. For example:
authClient.signIn.social({
provider: "google",
callbackUrl: "/todo"
})
authClient.signIn.social({
provider: "google",
callbackUrl: "/todo"
})
With this the expected behavior is to get redirected to lcoalhost:3000/todo after login. But I am getting redirected to localhost:4000/todo. Now I figured that, this is happening because google console has authorized redirect URI set to http://localhost:4000/api/auth/callback/google since localhost:4000 is the one that is making the request. So I have to pass the full frontend URL (localhost:3000/todo) as callback. Is there anyway I can set it up in the backend or better-auth server config so that I don't explicitly have to mention the full url, instead I can use the relative path as usual?
No description
No description
1 Reply
FalconiZzare
FalconiZzareOP•7d ago
@Ping @bekacru sorry for the mention 😦

Did you find this page helpful?