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

245
Views
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
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!