Problem: the app works when page loads but if I reload it, the identity is null.
In development I have two apps that share the same convex dev in the same monorepo. I run them one a a time in localhost:3000, so when i use one app i don't run the other one.
This is the function that is throwing when getUserIdentity. It works fine on the first call, but fails after that.
// convex/page.ts
export const getPage = query({
args: { customerId: v.optional(v.id("bz_customers")) },
handler: async (ctx, { customerId }) => {
const identity = await ctx.auth.getUserIdentity(); // works the first time.
if (!identity) throw new Error("Identidad no encontrada"); // throws on subsequent calls (reload of page or changing the args values from the react component hook useQuery)
//...etc
Dependency:
"convex": "^1.11.0",
The auth is managed with Clerk. I set a JWT template for each app, with the same applicationID: "convex"
// auth.config.js
// Both env variables are set in dashboard.convex.dev
export default {
providers: [
{ applicationID: "convex", domain: process.env.CLERK_JWT_ISSUER_DOMAIN }, // fentex.com
{
applicationID: "convex",
domain: process.env.BREZZA_CLERK_JWT_ISSUER_DOMAIN, // brezza.com
},
],
};
The other app works fine. it was the first one that i set up. The failure happens on the second app that I added.
The apps are in different url domains.
I wonder if it is a dirty state in the auth system.
Any idea how can I debug this?