I don’t think it changed because I’ve had this code before except I didn’t think it was relevant and it was posting to /home, I had the form data hosted on /login and then it matches it with the database and sends that data to /home which then makes a session for the user.
Here’s what it looks like on my project right now
how did you get/write this code that you have in server.js? it looks like it’s trying to do something else
I used some Chat GPT
now I’m curious how it suggests to fix this
What happens(I think) Is that when it uses res.send it sends a post to /home and redirects to there but because it’s a /post It doesn’t load the page or something like that which is why it says cannot POST /home
I just wanna have it POST and GET /home at the same time
tell them that this creates a race condition, and the process of logging in may or may not finish by the time it tries to check if the user is logged in
Well how do I have it post to something which checks the db and then lets them in if its correct which then redirects them to the /home page with the login info
I can’t simply use /POST because I need to use /GET to get the actual page but /GET doesn’t put the form data anywhere
what I usually see is you’d have the browser do the POST, then handle the login on the server, then the server redirects to /home, which causes the browser to send a second request, which is a GET
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.