Social login on server

Can I user social sign in on server like:
const session = await auth.api.signInSocial({
body: { provider, callbackURL },
});
const session = await auth.api.signInSocial({
body: { provider, callbackURL },
});
If I can, what's the proper way to do that? I'm currently using it inside a server action and better auth returns "Invalid URL" even though I've passed in the valid one to the callbackURL.
6 Replies
bekacru
bekacru3mo ago
don't pass a full url for callback like http://localhost:3000/dashboard just pass /dashboard. And since it can't redirect directly you'd need to redirect the user yourself from the response data.url
nainglinnkhant
nainglinnkhantOP3mo ago
I tried with "/" and "/dashboard" too. But didn't work.
bekacru
bekacru3mo ago
is it still returning invalid url?
nainglinnkhant
nainglinnkhantOP3mo ago
Yea, it's still returning invalid url. The provider is github.
bekacru
bekacru3mo ago
can you send the whole error message here?
nainglinnkhant
nainglinnkhantOP3mo ago
it's just the Invalid URL with the code "ERR_INVALID_URL".
No description

Did you find this page helpful?