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

183
Vistas
How to set cookie as xmlhttprequest header?

I am creating an API that post to 3rd party API . I need to fetch CSRF-Token and cookies, in order to post to that API. In the fetchCred I fetch CSRF-Token and cookies using getResponseHeader("set-cookie") and getResponseHeader("x-csrf-token") correctly.

Then I want to use these values in the Create.js to post data.

However, I can't set-cookies manually because JavaScript cannot set cookie headers, since it returns 400 Refused to set unsafe header "Cookie"

Is there a workaround on how to pass the fetched cookies in the post method cookie header?

fetchCred.js

request.open("GET", url, true);
request.setRequestHeader("Authorization", "Basic xxxxx");
request.setRequestHeader("X-CSRF-Token", "fetch");

create.js

request.open("POST", url, true);
request.setRequestHeader("Authorization", "Basic xxxxx");
request.setRequestHeader("X-CSRF-Token", token);
request.setRequestHeader("Cookie", cookie);

I would really appreciate your help

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