Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

152
Views
POST to backend is returning a 404. (React => Express)

I've made a fairly simple register/login form for my backend to save to a database. It was working a couple days ago, and now nothing. When I make the fetch call the payload is filled out appropriately. My terminal tells me 'POST /api/v1/users/register 404 13.504 ms - 161'. My fetch request looks like:

        const handleRegisterSubmit = async (e) => {
         e.preventDefault()
         await fetch('http://localhost:3333/api/v1/users/register', {
          method: 'POST',
          mode: 'cors',
          headers: {
            'Content-Type': 'application/json',
            'Accept': 'application/json'
          },
          body: JSON.stringify({
            dealershipname: registerForm.dealershipname,
            password: registerForm.password,
            streetadress: registerForm.streetadress,
            city: registerForm.city,
            state: registerForm.state,
            zip: registerForm.zip,
            phone: registerForm.phone,
            email: registerForm.email
           })
         })
        .then(res => res.json())
        .then(data => {
            if (data.error) {
                setError(data.error)
            } else {
                navigate('/porsche')
            }
        })
}

My backend route looks like:

    router.post('/register', async (req, res) => {
    // check for username and password on req
   if (!req.body.dealershipname || !req.body.password) {
     return res.status(400).json({
       error: 'Please include username and password'
     })
   }

  // check database for existing user 
  const user = await models.User.findOne({
    where: {
     dealershipname: req.body.dealershipname
    }
  })
 // if exists, send error
 if (user) {
   return res.json(400).json({
     error: 'Username already in use. Pick another'
   })
  }
// hash password
const hash = await bcrypt.hash(req.body.password, 10)
// create user
const newUser = await models.User.create({
   dealershipname: req.body.dealershipname,
   password: hash,
   streetadress: req.body.streetadress,
   city: req.body.city,
   state: req.body.state,
   zip: Number(req.body.zip),
   phone: Number(req.body.phone),
   email: req.body.email
  })

// respond with success message
 return res.status(201).json(newUser)
})

My server is running fine. I've set the backend port to 3333 in case that it just needed some room from the front end port. The errors I'm getting in the browser are the same thing. Any help or suggestions would be a lifesaver.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!