#AI Sass Pages Clerk Middleware Issue - Pages not responding - Still Needs Help
5 messages · Page 1 of 1 (latest)
Here's the issue
Why was my post deleted?!
Im gonna try to repost here:
So after deploying Im unable to access any of the routes that check for the user with getUserById
const Credits = async () => {
const { userId } = auth();
console.log("🚀 | CREDITS userId:", userId)
if (!userId) redirect("/sign-in");
console.log("🚀 | CREDITS passed USERID CHECK:", userId)
const user = await getUserById(userId); // <== this is null in production
console.log("🚀 | CREDITS user:", user)
return ()
}
export async function getUserById(userId: string) {
console.log(':rocket: | getUserById:', userId); //
try {
await connectToDatabase();
console.log(':rocket: | connectToDatabase:', 'connected?');
const user = await User.findOne({ clerkId: userId });
console.log(':rocket: | user:', user); // null
if (!user) throw new Error('User not found');
return JSON.parse(JSON.stringify(user));
} catch (error) {
handleError(error);
}
}
And here's a link to my connectToDatabase fn:
AI Sass Pages Clerk Middleware Issue - Pages not responding - Still Needs Help