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

438
Vistas
Axios is not passing cookies upon 302 redirect

I'm trying to implement an admin request submission class in node.js. There are two API calls, one is Login and the second is Request Access (Both are forms). I've managed to build these two API calls in Postman, however, I'm struggling with getting the same behavior in node.js. Probably because cookies are not passed correctly.

The login flow is: Send POST request to https://{{base_uri}}/hc/web/siteadminlogin/siteadmin/AdminAccess.jsp With form data and Content-Type: application/x-www-form-urlencoded

The response from this call is 302 redirect that sets these two cookies:

Set-Cookie: WSHumanClickWebSession=816d619eddd19ee46ac03bf88b381; path=/hc/web; secure; HttpOnly

Set-Cookie: WSHumanClickServer=z1-e-dnv6969; path=/hc/web; secure

Then the redirect triggers a GET request to the following URL: https://{{base_uri}}/hc/web/siteadmin/siteadmin/AdminAccess.jsp?site={{form_data_site}}

With the cookies from the initial POST response.

Postman handles cookie storage automatically, however, in Axios these cookies are not passed correctly to the 302 redirect. Causing the login to fail and return back to the login page.

This is what I have in node:

    const qs = require('qs');
    const data = qs.stringify({
        'user_name': 'user_name',
        'password': 'user_pass!!',
        'site_number': 'site_num',
        'But1':'Submit'
    });
    const config = {
        method: 'post',
        url: 'https://base_uri/hc/web/siteadminlogin/siteadmin/AdminAccess.jsp',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
        data : data,
        withCredentials: true,
    };
    try {
        const response = await axios(config);
        console.log(response.headers);
        console.log(response.data);
    }catch (e) {
        console.log(e)
    }

It's either the form data is not being submitted correctly or the cookies are not being stored and passed between the requests. Any ideas on how to solve this?

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