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

244
Vistas
Request returns 404 when verifying the token with jwt, node/express

I have two main folders that have to do with the issue: routes and controller. In the routes folder, I declare the paths and also call the corresponding controller:

router.get('/my-route', testController.method);

And in the controller I'm using jwt to verify the token of the current user:

testController.method= verifyToken , (req, res) => {
  res.send("test")
};

This returns 404 error.

However, if I cut the "res.send" and I paste it in the verifyToken method, it returns 200 + "test", so it just ignores what happens after the verifyToken function(?)

However, when I join the route and the controller in the same file, it works just fine. Something just like this:

router.get('/my-route', verifyToken, (req, res)=>{
    res.json("test")
});

I'm pretty sure that I'm not moving around the files well (the verifyToken is a function located in another file in the controllers folder), but I am fairly new to js, so I'm not sure why is this happening.

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