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

227
Visualizações
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 à 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