Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

165
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda