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

127
Vistas
Unable to receive authorization headers in express backend?

I am making an MERN app. Inside useEffect I am making a API Call in which I am setting a autorizarion token. But I am unable to get authorization token from headers in the backend.

useEffect(()=>{
    fetch(`${API}/${userId}/courses`,{
        method:"GET",
        'Authorization': `Bearer ${token}`,
        'Content-Type': 'application/json'
    }).then(response=>{
        return response.json();
    }).then(data=>{
        console.log(data)
    })

})

If I try to console.log req.headers in backend I am getting response as:

{ host: 'localhost:3030',
  connection: 'keep-alive'
  origin: 'http://localhost:3000',
  referer: 'http://localhost:3000/',
}

There is no authorization property in it. But if I try to make same api call from POSTMAN I am getting authorization token in headers. What's the problem?

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

0

You have to wrap the headers to key headers in arguments Object.

fetch('${API}/${userId}/courses',{
        method:"GET",
        headers: {
          'Authorization': 'Bearer ${token}',
          'Content-Type': 'application/json'
        }
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