cps-user3C
Convex Community2y ago
10 replies
cps-user3

Null Response from ctx.auth.getUserIdentity() in Next.js API

Hello. I am using Auth0 to verify user authentication.
I have created a Next.js app and a Flutter app using the same Auth0 domain, and I am fetching data for the Flutter app from the Next.js API.
Could you please suggest a good way to use await ctx.auth.getUserIdentity()? Currently, the result is always null.

convex/users.ts
export const getUser = query({
handler: async (ctx) => {
const identity = await ctx.auth.getUserIdentity();

return identity
}
});

api/users/route.ts
export async function GET(req: NextRequest) {
const user = await fetchQuery(api.users.getUser);
return NextResponse.json(user);
}
Was this page helpful?