HELP!! Cause of third-party cookie blocked, I've tried to use Token instead of Cookies, but...

FrontEnd: React BackEnd: Express //auth-client.ts import { createAuthClient } from "better-auth/react"; export const authClient = createAuthClient({ baseURL: import.meta.env.VITE_BETTER_AUTH_BASE_URL, fetchOptions: { auth: { type: "Bearer", token: () => localStorage.getItem("bearer_token") || "", }, }, }); export type Session = typeof authClient.$Infer.Session; export const { signIn, signOut, signUp, useSession, getSession, forgetPassword, resetPassword, } = authClient; // SignIn.tsx const handleGoogleSignIn = async () => { await signIn.social({ provider: "google", callbackURL: "http://localhost:5173/dashboard", fetchOptions: { onRequest: () => setLoadingAction("google"), onResponse: () => setLoadingAction(null), onSuccess: async (ctx) => { setLoadingAction(null);
const authToken = ctx.response.headers.get("set-auth-token"); if (authToken) { localStorage.setItem("bearer_token", authToken); } await refreshSession(); toast.success("Redirecting user to..."); navigate("/dashboard"); }, onError: (ctx) => { console.log(ctx.error.message); toast.error("Failed to Sign In."); }, }, }); }; //auth.ts export const auth = betterAuth({ database: prismaAdapter(prisma, { provider: "postgresql", }), baseURL: "http://localhost:3000", .... plugins: [bearer()], }); And it seems, I've never got the AuthToken from the ctx.reponse. Can anyone help me with this?
2 Replies
Mukund
Mukund5d ago
This auth.ts is in express server?
Jaa
JaaOP4d ago
Yes, my question was an issue and it has a PR, I think it is being addressed.

Did you find this page helpful?