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

467
Views
req.headers('Autorización') no está definido

Tengo problemas con este código porque el token no está definido.

En mi interfaz:

 export const fetchUser = async (token: any) => { const res = await axios.post('/user/getuser', { headers: {Authorization : token} }); return res; };

Y en mi middleware es:

 const jwt = require('jsonwebtoken'); import {Request, Response, NextFunction} from 'express'; const auth = (req: Request | any, res: Response, next: NextFunction) => { try { const token = req.headers('Authorization'); console.log(token); if(!token) return res.status(400).json({msg: 'Invalid Authentication.'}); jwt.verify(token, process.env.ACCESS_TOKEN as string, (err: any, user: any) => { if(err) return res.status(400).json({msg: "Invalid Authentication token"}) req.user = user; next(); }); } catch (error: any) { return res.status(500).json({msg: error.message}); } } module.exports = auth;

Lo he probado en Postman y no hay problema, sin embargo, hay un problema cuando hago solicitudes desde mi interfaz.

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!