Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

253
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda