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

220
Vistas
Making an API call to Jenkins not working

Hi I am new to working with the Jenkins API, and I want to know why my current implementation is not working with the fetch API. I have tested its implementation with postman, and it works fine, however, when I use the fetch API in a node vue.js project, I getting a CORS error when I set the request mode to use cors, and a 403 forbidden error when I am using the no-cors mode. Here is my code that I currently have for my implementation:

fetch("https://<domain-url>/crumbIssuer/api/json",{
    method:'GET',
    mode: 'cors', //<=== cors request mode set here
    headers:{
        'Authorization': 'Basic <hashed username and password for jenkins basic authentication>',
        'Content-Type': 'application/json',
    },
}).then(res=>{
    if(res.ok){
        return res.json();
    }else{
        ....
    }
}).then(data=>{
    ....
}).catch(()=>{
    .....
});

If I use this code, I get a CORS error as shown in the following image: Jenkins CORS Error However, I do suspect that this can be fixed via the implementation of a proxy. Although, I would like to know if my fetch was just simply misconfigured in some way, such as the URL, headers, etc.

NOTE: I am using the exact same URL on my postman implementation: Setup in postman

Also, I tried setting the request mode to no-cors and got a 403 error: 403 error However, according to the article that I have linked below, setting the request mode to no-cors is not a good idea since it prevents front-end javascript code from reading the response body. Here is a link to that article:

Trying to use fetch and pass in mode: no-cors

I'm not sure why it returns a 403 forbidden error when in no-cors though.

I'm really thinking that a proxy server could solve this issue, but any other suggestions would be great. (Or pointing out a stupid mistake) thanks!

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