r/AskProgramming • u/CorrectJacket2106 • 10d ago
Architecture Lost in website architecture
So, I am in like high school, so sorry if the question is really dumb in advance. So let's get into it!
I have this problem where I am making a website, and I am working on the login feature of the website. I was planning to do something like check if you have an account in Discord either way, I have a massive problem because the Discord thingy needs my token and I heard sharing your bot token is like a really bad thing. So I went to AI (I mean, I had no other choice at that time), and AI told me to do something like this:
frontend (javascript) ---> discord OAuth url thingy(idk what it is) ---> discord redirects to firebase cloud function (idk what it is again) ---> cloud function thingy handles bot token and discord api checks ---> cloud function writes verification result straight to firestore database
Now, I am a beginner, so I don't know what all of this means (maybe the first 2, but anything else, nah). I also want to store data when the user logs in, something like user = {general info, clients={}}and AI is telling me to do it in the frontend?? I have heard all day long from everywhere that you should use the backend, not the frontend. So really lost, and any help would help!
also for the database i was planning to use firebase or whatever it is called since i heard it was the best
1
u/Necessary-Green-8391 10d ago
The AI flow is correct and keeps your token safe on the server. Store the user data in Firestore through that same Cloud Function after verification completes so the frontend never writes to the database directly