adrianhajdin/ai_saas_app

Error: User not found

Saxar88 opened this issue · 4 comments

I get this error whenever I click on any of the buttons in the navbar. I thought maybe I did something wrong in my build, so I copied yours, added my .env.local, ran npm i, then npm run dev, but I get the same error. Did I make a mistake in Clerk or MongoDB?

Oddly enough, everything was fine initially. I was on the deployed version. I clicked on Generative fill, selected a picture from Unsplash, picked an aspect ration, and it transformed it, but the AI messed up, so I wanted to try a different picture. There is no cancel button, so I just clicked on the back button in the browser. After that it stopped working...

On the deployed version I get this error even on the home page.

Hello
I had the error you are having at one point while I was building this app. The first thing I did was try to isolate the error as much as possible, see if my code was wrong, or if it was a database problem, or some misconfiguration in the clerk provider.
If it is the same error that I had, the error is in the database, I don't remember exactly how I solved it because I tried many alternatives, but you can start with this:

  • Change the password of the user who has access to the database.
  • Create a new cluster
  • Enter many console.log to see exactly when it returns data and when it does not

I hope it helps you, at one point I seriously considered changing mongoose for Prisma ORM, ironically while doing it I found the solution and stayed in mongoose.

@Saxar88 is your user data being stored inside the database?

@Saxar88 is your user data being stored inside the database?

Yes, I have 2 users in my database: one from logging in with Google, and one with GitHub.

The issue was with Clerk. The Database requires a username, but for some reason when signing in with the Google account, the username didn't pass through.

To fix it I went to Clerk>User & Authentication>Email, Phone, Username, and enabled the Username option. Saved, deleted the user, signed up again in with Google, and was prompted to set a username.

Now everything works fine.