Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

443
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda