#AI Sass Pages Clerk Middleware Issue - Pages not responding - Still Needs Help

5 messages · Page 1 of 1 (latest)

full yew
#

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:

https://github.com/gaurangrshah/imaginer/blob/061e1719532489c6778fc7ef6c23e551ddc273d0/lib/db/mongoose.ts#L19C1-L52C3

GitHub

Contribute to gaurangrshah/imaginer development by creating an account on GitHub.

#

AI Sass Pages Clerk Middleware Issue - Pages not responding - Still Needs Help