adrianhajdin / project_next_14_ai_prompt_sharing

Next.js recently became the official React framework as outlined in React docs. In this course, you'll learn the most important Next.js concepts and how they fit into the React ecosystem. Finally, you'll put your skills to the test by building a modern full-stack Next 14 application.
https://www.jsmastery.pro/ultimate-next-course
2.83k stars 416 forks source link

Can't conneted with the MongoDB backend #70

Open Pannu786 opened 11 months ago

Pannu786 commented 11 months ago

I have tried everything. Even looked into the other solved solutions but nothing seems to work for me,

honxsinatra commented 10 months ago

What error exactly are you facing? Can you share the shots?

Pannu786 commented 10 months ago

What error exactly are you facing? Can you share the shots?

That's the thing I'm not getting any errors. all is working fine except for the backend. I am not able to see my data in cluster inside mongoDB.

honxsinatra commented 10 months ago

What error exactly are you facing? Can you share the shots?

That's the thing I'm not getting any errors. all is working fine except for the backend. I am not able to see my data in cluster inside mongoDB.

can you share your route file in [...nextauth] folder? However make sure in your route file you are using "callbacks" and not "callback" and keep in mind that the match used in the video does not allow other user to sign in once their name have more than one space in between their name, to avoid the validation error make sure to change from "username: profile.name.replace(" ", "").toLowerCase()" to "username: profile.name.replace(/ /g, "").toLowerCase()" image

honxsinatra commented 10 months ago

correction Look around the red marked area

honxsinatra commented 10 months ago

Don't hesitate to ask further info once you won't understand or solve your bug.

What error exactly are you facing? Can you share the shots?

That's the thing I'm not getting any errors. all is working fine except for the backend. I am not able to see my data in cluster inside mongoDB.

Pannu786 commented 10 months ago

Don't hesitate to ask further info once you won't understand or solve your bug.

What error exactly are you facing? Can you share the shots?

That's the thing I'm not getting any errors. all is working fine except for the backend. I am not able to see my data in the cluster inside MongoDB.

Hey @honxsinatra . I hope you are doing great. I have tried exactly what you mentioned me above. Unfortunately, it doesn't seem to work for me. My main issue is my backend doesn't seem to connect with the frontend thus no user data is getting saved in the database maybe it has something to do with the cluster which I am not able to fix. My works fine without adding "s" on callback but when I added "s" it broke and told me "access dined". I have attached the file shots you asked for. Please have a look once you have time. I appreciate your help tho.

here the app is working all right without adding "s" but is not able to communicate with the backend and the user data is not stored in the mangoDB database. without callbacks

here app breaks down when adding "s" with a callback with callbacks

route file shot-1 route file-1

route file shot-2 route file-2

user file shot-1 user file-1

user file shot-2 user file-2

database file database file-1

I am aware .eve file should be kept secret lol but since this is not a real project I don't mind sharing it here .. env file

here is the cluster which seems to be created successfully and all but not getting any data in.. mangoDB is not connected

honxsinatra commented 10 months ago

hello @Pannu786 , I am really sorry for the challenge you have faced, the problem of access denied is always coming from the username requirements, that's the username you are trying to sign in with does not meet therequirement of match so try the following match and replace it to your match from "user.js" file;

match: [ /^(?=[a-zA-Z0-9\s()]{6,25}$)(?![.])(?!.*[.]{2})[a-zA-Z0-9\s()]+(?<![_.])$/, "Username invalid, it should contain 6-25 alphanumeric letters and be unique!", ]

See the short below

image

honxsinatra commented 10 months ago

@Pannu786 The global match above allows any username to be valid. You can customize it, but the more you specify, the more usernames you exclude.

honxsinatra commented 10 months ago

Don't hesitate to reach me out if it won't work

Pannu786 commented 10 months ago

/^(?=[a-zA-Z0-9\s()]{6,25}$)(?![.])(?!.*[.]{2})[a-zA-Z0-9\s()]+(?<![_.])$/, "Username invalid, it should contain 6-25 alphanumeric letters and be unique!", ]

Sorry, but It still doesn't seem to work for me. When I remove "s" from the "callbacks" the app runs without any issues and I can sign in easily. I just want the mangoDB cluster to work and store the user data.

replace

Pannu786 commented 10 months ago

any other tips you have that I should try? @honxsinatra

honxsinatra commented 10 months ago

When you remove the 's' from 'callback', the code inside the sign-in function will not be executed. Therefore, you need to use 'callbacks' instead of 'callback'. However, to address your issue, please share the error you encounter when using 's'. Providing a screenshot would be greatly appreciated.

any other tips you have that I should try? @honxsinatra

divyanshucode commented 9 months ago

any other tips you have that I should try? @honxsinatra

Did you try removing <> this bracket from your password in mongodbUri i think bracket should not be included , also i am stuck in same situation where adding s to callback login works and cluster is not saving the login information

Hemanth12-git commented 2 months ago

@divyanshucode thanks alot bro i was stuck on for hrs , but finally this worked on lol.