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

131
Vistas
Request interceptors not modifying the value of request header in node js

I am using http-proxy-middleware to create a proxy and it's running successfully. Before calling app.use('/',proxy_options); I am trying to intercept my request and modifying the request header but updated value is not reflecting in headers.

app.use('/',(req,res,next)=>{
const token=getToken();
req.header['authorization']=token;
next();
});

Even I tried with req.header.authorization=token; and also without next();. When I am trying to print the my request header authorization:'' is coming as blank. Can any one let me know why this happening and how I can resolve this.

Any help or suggestions must be appreciated.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If your getToken() function is fetching token from other apis, then you should add await in front of it.

Try to use below code,

app.use('/', async (req,res,next)=>{
const token=await getToken();
req.headers['authorization']=token;
next();
});

You also need to replace header by headers, as mentioned above in code snippet.

It should work.

about 4 years ago · Juan Pablo Isaza Denunciar
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