cabbage
cabbage2mo ago

using convex auth & nextjs router. using router.back() does not refresh auth in time.

i have a convex & nextjs app. convex api that runs on the main page:
export const get = query({
handler: async (ctx) => {
const userId = await getAuthUserId(ctx);
if (userId === null) {
throw new Error("Not signed in");
}
return await ctx.db
.query("notepads")
.filter((q) => q.eq(q.field("userId"), userId))
.order("desc")
.collect();
},
});
export const get = query({
handler: async (ctx) => {
const userId = await getAuthUserId(ctx);
if (userId === null) {
throw new Error("Not signed in");
}
return await ctx.db
.query("notepads")
.filter((q) => q.eq(q.field("userId"), userId))
.order("desc")
.collect();
},
});
when i go to a subpage and click the back button to go back to main (via router.back() or router.push()), it gives me this "not signed in error". from console logging, it seems like getAuthUserId is returning null and not updating. it seems to be saving the "is Authenticated" state do you have recommendations?
No description
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?