Arnav
Arnav
BABetter Auth
Created by Arnav on 2/28/2025 in #help
getSession Headers Type
Update: I wasn't including credentials: true in my fetch call to hit the endpoint, after that it started working. For the typing, this worked:
app.post('/print_auth', async (req: Request, res: Response) => {
const session = await auth.api.getSession({
headers: new Headers(req.headers as Record<string, string>),
});
console.log(session);
res.json({ success: true });
});
app.post('/print_auth', async (req: Request, res: Response) => {
const session = await auth.api.getSession({
headers: new Headers(req.headers as Record<string, string>),
});
console.log(session);
res.json({ success: true });
});
4 replies
BABetter Auth
Created by APPLE on 2/28/2025 in #help
base path not resolving correctly
I'm using express, and my baseURL in createAuthClient was 'http://localhost:3000' without a '/auth' in front of it. Another issue you might have is that you have to set the callback URL to a full URL. i.e.
const { error } = await authClient.signIn.social(
{
provider: 'google',
callbackURL: 'http://localhost:5173/home',
newUserCallbackURL: 'http://localhost:5173/home',
},
{
onError: (error) => {
console.error(error);
},
},
);
const { error } = await authClient.signIn.social(
{
provider: 'google',
callbackURL: 'http://localhost:5173/home',
newUserCallbackURL: 'http://localhost:5173/home',
},
{
onError: (error) => {
console.error(error);
},
},
);
instead of just
callbackURL: '/home'
callbackURL: '/home'
Not sure if this is helpful, but I had a similar issue and that's what worked for me.
5 replies