JWT and avoid cookies

Hi All, I've got multiple projects pointing to different domains (vs hosted) for the backend and I'd like to use JWT For auth. I have enabled both JWT and Bearer plugins. However, it still tries to go through the cookie route when trying to getSession via
try {
const session = await auth.api.getSession({
headers: fromNodeHeaders(req.headers),
});

if (!session || !session.user || !session.session) {
throw new UnauthorizedError();
}

req.user = session.user as User;
req.session = session.session as Session;

next();
} catch (err) {
return next(err);
}
try {
const session = await auth.api.getSession({
headers: fromNodeHeaders(req.headers),
});

if (!session || !session.user || !session.session) {
throw new UnauthorizedError();
}

req.user = session.user as User;
req.session = session.session as Session;

next();
} catch (err) {
return next(err);
}
I'd like better-auth to validate the token if possible but it looks like I have to use a 3rd party or create one correct?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?