In auth.config.ts I provided (local for
In auth.config.ts I provided (local for now)
export default {
providers: [
{
domain: "http://localhost:8787",
applicationID: "http://localhost:8787",
},
],
};
and in my route.ts I have:
function Layout() {
const convex = useConvex();
useEffect(() => {
// Set the auth fetcher function once when the layout mounts.
convex.setAuth(fetchToken);
}, [convex]);
return <Outlet />;
}
where fetchToken is just fetching the token from the local server. I verified that fetchToken is indeed called. However, when I checked with a sample mutation
export const example = mutation({
handler: async (ctx) => {
const identity = await ctx.auth.getUserIdentity();
console.log({ identity });
return true;
},
});
the identity is null.
2 Replies
See https://docs.convex.dev/auth/debug and look at the WebSocket messages you're getting back when auth is (presumably) rejected
Debugging Authentication | Convex Developer Hub
Troubleshoot authentication issues in Convex
Thanks, I’ve been able to verify everything. The only thing missing is the “typ” in HEADER. Is this strictly necessary? I’m using the jwt plugin from better-auth, do you think there’s a way to add this header to the jwt token in case it’s required?
Actually I think I’ve found the problem: auth.config.js is set to http://localhost:8787 and convex dev is not able to fetch the jwks. I’m not sure now how to proceed, I don’t want to have to use prod to be able to test jwt auth.