adrianhajdin / threads

Develop Threads, Next.js 13 app that skyrocketed to 100 million sign-ups in less than 5 days, and dethroned giants like Twitter, ChatGPT, and TikTok to become the fastest-growing app ever!
https://threads-psi.vercel.app
1.47k stars 279 forks source link

Failed to create communities inside the MongoDB #48

Open giannis198 opened 1 year ago

giannis198 commented 1 year ago

The Communities are not stored in my db after creating them

TariQMah commented 1 year ago

same goes for me. still finding the answer

roshinys commented 1 year ago

for me i didnt add profile photo so it threw error add profile photo might solve issue

TariQMah commented 1 year ago

for me, i put some extra white space in my environment vairable


From: roshinys @.> Sent: Tuesday, August 15, 2023 3:30 PM To: adrianhajdin/threads @.> Cc: TariQMah @.>; Comment @.> Subject: Re: [adrianhajdin/threads] Failed to create communities inside the MongoDB (Issue #48)

for me i didnt add profile photo so it threw error add profile photo might solve issue

— Reply to this email directly, view it on GitHubhttps://github.com/adrianhajdin/threads/issues/48#issuecomment-1678727163, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AFBJKJXDGQJGI36CFPWBSJTXVNFTTANCNFSM6AAAAAA3O2STNE. You are receiving this because you commented.Message ID: @.***>

kashanhz999 commented 1 year ago

Do you guys got any solution???

giannis198 commented 1 year ago

i believe something is wrong with the code in app/api/webhook/clerk/route.ts file

lamfeng commented 1 year ago

1.) Just copy and paste the code from https://github.com/adrianhajdin/threads/blob/main/app/api/webhook/clerk/route.ts to your route.ts file. (Make sure DON'T formatting the code)

2.) Log in to your Clerk account and check your Clerk's endpoint is pointing to your Vercel URL. Example: https://threads-app-nextjs-xxxxx.vercel.app/api/webhook/clerk

3.) Remember to Update NEXT_CLERK_WEBHOOK_SECRET in your env file and environment variables on the Vercel.

4.) Push your latest code to GitHub and Redeploy to Vercel.

5.) PATIENCE and wait until the deployment is complete.

6.) Create an organization for testing.

You also can go to Clerk's dashboard > Webhooks > Logs > organizationMembership.created and check the Webhook Attempts. Inside there has our server's response. (May help you debugging) If Succeeded, your communities data will be stored in your MongoDB.

kashanhz999 commented 1 year ago

1.) Just copy and paste the code from https://github.com/adrianhajdin/threads/blob/main/app/api/webhook/clerk/route.ts to your route.ts file. (Make sure DON'T formatting the code)

2.) Log in to your Clerk account and check your Clerk's endpoint is pointing to your Vercel URL. Example: https://threads-app-nextjs-xxxxx.vercel.app/api/webhook/clerk

3.) Remember to Update NEXT_CLERK_WEBHOOK_SECRET in your env file and environment variables on the Vercel.

4.) Push your latest code to GitHub and Redeploy to Vercel.

5.) PATIENCE and wait until the deployment is complete.

6.) Create an organization for testing.

You also can go to Clerk's dashboard > Webhooks > Logs > organizationMembership.created and check the Webhook Attempts. Inside there has our server's response. (May help you debugging) If Succeeded, your communities data will be stored in your MongoDB.

Inside Webhooks > Logs its showing organization.created but in mongoDB it is not reflecting. I have added both screenshots

Screenshot 2023-08-21 at 1 02 58 PM Screenshot 2023-08-21 at 1 03 56 PM
lamfeng commented 1 year ago

@kashanhz999 Click the organizationMembership.created to check. image

Op-Pautu commented 1 year ago

@lamfeng how did u successfully deploy in vercel? i could not and now am stuck

kashanhz999 commented 1 year ago

@lamfeng I'm getting response code 200

Screenshot 2023-08-21 at 2 25 06 PM
lamfeng commented 1 year ago

@kashanhz999 1.) Your endpoints should be "https://threads-kh.vercel.app/api/webhook/clerk", Not "https://threads-kh.vercel.app"

2.) After update the endpoints, You also need update the new (Signing Secret) to NEXT_CLERK_WEBHOOK_SECRET in your env file and environment variables on the Vercel.

3.) Redeploy to your project on Vercel and wait until deployment is complete.

4.) Try create an organization again.

lamfeng commented 1 year ago

@Op-Pautu Based on the YouTube Tutorial: https://youtu.be/O5cmLDVTgAs?t=18332 Instructor also failed deploy at the first time due to have some build errors.

1.) You need update the configuration in your next.config.js. typescript: { ignoreBuildErrors: true, },

2.) git push to your Github and redeploy again.

kashanhz999 commented 1 year ago

@lamfeng

Screenshot 2023-08-21 at 2 52 58 PM
lamfeng commented 1 year ago

@kashanhz999 Double check your environment variable NEXT_CLERK_WEBHOOK_SECRET on Vercel. It must be same with Clerk's Signing Secret. After update the environment variable, remember to Redeploy again.

image

image

kashanhz999 commented 1 year ago

@lamfeng Thank you so much. It successfully solved the issue.

NandiniBure commented 1 year ago

i was facing the same error so i followed the same things you mentioned above but still new orginizition is not showing in database

Screenshot 2023-08-23 120244

kashanhz999 commented 1 year ago

@NandiniBure After you updated your endpoint to something like "https://threads-kh.vercel.app/api/webhook/clerk" from "https://threads-kh.vercel.app/" have you updated your NEXT_CLERK_WEBHOOK_SECRET ??

NandiniBure commented 1 year ago

yes and also redeployed

kashanhz999 commented 1 year ago

Could you clarify if you are trying to create communities from "http://localhost:3000/" ??

NandiniBure commented 1 year ago

yes

kashanhz999 commented 1 year ago

Try creating communities from the deployed url

NandiniBure commented 1 year ago

i tried but still not working

kashanhz999 commented 1 year ago

what is the status response code now??

i was facing the same error so i followed the same things you mentioned above but still new orginizition is not showing in database

Screenshot 2023-08-23 120244

NandiniBure commented 1 year ago

same 500

kashanhz999 commented 1 year ago

what is your webhook end point ?

kashanhz999 commented 1 year ago

I have cloned your repository and it is working fine with me so I guess there might be some errors with your ".env.local" file or web-hook endpoints.

NandiniBure commented 1 year ago

yeah its working now.... I created a new project in vercel maybe i was doing something wrong earlier Thank You

baxsm commented 1 year ago

The clerk will make api calls to the Deployed version and not your local. If you make any changes to your local files (if you are following the tutorial, you might have to copy/paste some of the action files and the route file), make sure to deploy these changes. Also double check your local and production env variable for clerk and you're golden!

giannis198 commented 1 year ago

In the deployed code from YouTube tutorial Adrian must made changes in other files in 05:20:00 besides user.actions.ts and community.actions.ts because i found many differences from the main code.i will try to define them and i will inform you

debsouryadatta commented 1 year ago

Hey I have done the above stuffs but still it gives me an error of 405 Screenshot 2023-09-02 013155

debsouryadatta commented 1 year ago

@kashanhz999 @lamfeng please help me out in this

IrisWRX commented 1 year ago

1.) Just copy and paste the code from https://github.com/adrianhajdin/threads/blob/main/app/api/webhook/clerk/route.ts to your route.ts file. (Make sure DON'T formatting the code)

2.) Log in to your Clerk account and check your Clerk's endpoint is pointing to your Vercel URL. Example: https://threads-app-nextjs-xxxxx.vercel.app/api/webhook/clerk

3.) Remember to Update NEXT_CLERK_WEBHOOK_SECRET in your env file and environment variables on the Vercel.

4.) Push your latest code to GitHub and Redeploy to Vercel.

5.) PATIENCE and wait until the deployment is complete.

6.) Create an organization for testing.

You also can go to Clerk's dashboard > Webhooks > Logs > organizationMembership.created and check the Webhook Attempts. Inside there has our server's response. (May help you debugging) If Succeeded, your communities data will be stored in your MongoDB.

@lamfeng Thank you soooooo much!! I've been stuck where the date and community won't render in the thread post. Turns out I need to push the latest code to Github and redploy as you suggested. Thank youuuuuuuuuuu!!

debsouryadatta commented 1 year ago

@kashanhz999 @lamfeng please help me out in this

Sorry for disturbing, the error got fixed, I just forgot to add the clerk folder lol🤣

anmolsahu25 commented 11 months ago

Screenshot 2023-09-17 145827 Screenshot 2023-09-17 145801 can somone help me with this error

mhmadamrii commented 10 months ago

Screenshot 2023-09-17 145827 Screenshot 2023-09-17 145801 can somone help me with this error

hey bro, after spending 3 days debuggin I solved the issue

mhmadamrii commented 10 months ago

import { authMiddleware } from '@clerk/nextjs/server';

export default authMiddleware({ publicRoutes: ["/api/webhook/clerk"], ignoredRoutes: ["/((?!api|trpc))(_next.*|.+.[\w]+$)", "/api/webhook/clerk"] })

// Stop Middleware running on static files export const config = { matcher: ['/((?!.+\.[\w]+$|_next).)', '/', '/(api|trpc)(.)'], };

you need to modify authMiddleware like my code above, the message "string src property..." is caused by blocked authMiddleware, I figured it out after finding an error message at runtime in logs at vercel deployment

vusal5555 commented 8 months ago

Hi guys, almost finished the course but stuck at this problem. I did everything exactly as it is supposed to be done still no data shown on my website or in the database. here is my repo: https://github.com/vusal5555/ThreadWeave

srp8 commented 2 months ago

Hello, My date, time and community won't render on my deployed website and also the community doesn't render into mongoDB but my clerk showed logs of the community being created but it won't show up on the website. I have tried all of the suggestions above but they do not work for me! Can anyone help Please? Here is the link to my repo: https://github.com/srp8/Dr.eam image