ai_saas_app
ai_saas_app copied to clipboard
Unhandled Runtime Error Error: Error:
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?
I'm facing the same issue, it says user not found and new user is not getting created in the database
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;
Hey @Nagakburos Make sure your logged-in account is present in your mongodb database, error will be resolved
Manubenakal thank you! realy is it but, i try and i cant resolve yet, the user is not create on my MongoDB Query
I am still facing such a problem. How can I solve this problem by creating a new user in the database?
Hey @Nagakburos , Please check once with middleware.ts and db connection url
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
@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.
@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