ai_saas_app icon indicating copy to clipboard operation
ai_saas_app copied to clipboard

Unhandled Runtime Error Error: Error:

Open Nagakburos opened this issue 1 year ago • 10 comments

Hello good afternoon all right? I am facing the following error when completing the ( [...]/saasai/app/(root)/transformations/add/[type]/page.tsx) settings, can you help me?

Nagakburos avatar Feb 28 '24 21:02 Nagakburos

Captura de tela de 2024-02-28 18-12-03

Nagakburos avatar Feb 28 '24 21:02 Nagakburos

I'm facing the same issue, it says user not found and new user is not getting created in the database

Kshitijgupta23 avatar Feb 28 '24 23:02 Kshitijgupta23

I CORRECTED IT LIKE THIS, BUT NOW THE TITLE AND SUB TITLE ARE NOT RETURNING ON THE SCREEN

The Code file:

page.tsx:

import Header from '@/components/shared/Header' import TransformationForm from '@/components/shared/TransformationForm'; import { transformationTypes } from '@/constants' import { getUserById } from '@/lib/actions/user.actions'; import { auth } from '@clerk/nextjs'; import { redirect } from 'next/navigation';

const AddTransformationTypePage = async ({ params: { type } }: SearchParamProps) => { const { userId } = auth(); const transformation = transformationTypes[type];

if (!userId) { redirect('/sign-in'); return null;
}

let user = null; try { user = await getUserById(userId); } catch (error) { console.error('Erro ao buscar usuário:', error);

return null;

}

if (!user) { console.error('Usuário não encontrado com o ID:', userId); return null; }

return ( <> <Header title={transformation.title} subtitle={transformation.subTitle} />

  <section className="mt-10">
    <TransformationForm 
      action="Add"
      userId={user._id}
      type={transformation.type as TransformationTypeKey}
      creditBalance={user.creditBalance}
    />
  </section>
</>

); }

export default AddTransformationTypePage;

Captura de tela de 2024-02-29 14-58-05

Nagakburos avatar Feb 29 '24 18:02 Nagakburos

Hey @Nagakburos Make sure your logged-in account is present in your mongodb database, error will be resolved

Manubenakal avatar Mar 01 '24 10:03 Manubenakal

Manubenakal thank you! realy is it but, i try and i cant resolve yet, the user is not create on my MongoDB Query

Nagakburos avatar Mar 01 '24 19:03 Nagakburos

I am still facing such a problem. How can I solve this problem by creating a new user in the database?

Jaber-Saed avatar Mar 01 '24 20:03 Jaber-Saed

Hey @Nagakburos , Please check once with middleware.ts and db connection url

Manubenakal avatar Mar 02 '24 02:03 Manubenakal

Hey @Jaber-Saed , Go to clerk/dashboard, click on user section and delete the logged in users and sign up again. Lmk if it works And Also share error screenshots

Manubenakal avatar Mar 02 '24 02:03 Manubenakal

@Jaber-Saed @Nagakburos if the user is not being created inside the database, then you need to check whether you're running your app on local host or Vercel. The webhook secret key (Clerk) works when you host your app on Vercel. Go to clerk dashboard -> web hooks -> end points -> https://my-app.vercel.app/api/webhooks/clerk. make sure to host your app on vercel before creating this endpoint. after that try creating an account on imaginfy hosted at https://my-app.vercel.app .if you try to create an account on imaganify while running it on local host, the web hook won't work and the user created on clerk dashboard will not be stored inside mongo Db. hence causing the user not found error.

MusaMasroor avatar Mar 06 '24 23:03 MusaMasroor

@Jaber-Saed @Nagakburos if the user is not being created inside the database, then you need to check whether you're running your app on local host or Vercel. The webhook secret key (Clerk) works when you host your app on Vercel. Go to clerk dashboard -> web hooks -> end points -> https://my-app.vercel.app/api/webhooks/clerk. make sure to host your app on vercel before creating this endpoint. after that try creating an account on imaginfy hosted at https://my-app.vercel.app .if you try to create an account on imaganify while running it on local host, the web hook won't work and the user created on clerk dashboard will not be stored inside mongo Db. hence causing the user not found error.

Then how to solve this issue. I'm also facing this issue. I retried to create an endpoint in webhook secret key and also saved the secret key in .env local but I can't solve this issue. I completed whole video and deployed it in versel then it say

Application error: a server-side exception has occurred (see the server logs for more information). Digest: 3835239340

I recheck the public route in middleware.ts and add publicRoutes: ['/', 'api/webhooks/clerk', 'api/webhooks/stripe'] Then why did I get this error

Surajj-00 avatar Mar 10 '24 16:03 Surajj-00