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

117
Visualizações
Unable to see Content-Disposition header in create-react-app

I've a create-react-app with which is served from express. Express is serving only as a proxy for the app. The application logic is in CRA.

I'm trying to call an API and to download a file. The api responds back with a "Content-Disposition" header which contains the file name. I'm unable to retrieve the header in my call.

When I call the API in Postman/chrome-dev-tools, I can see the header available.

Please see my code below. The filename code is commented out because res.headers is empty.

let filename = 'test-file-name'; // <--- default file name
const output = fetch(transactionReportPath(), {
    headers: {
      accept: 'text/csv',
      Authorization: `Bearer ${getToken()}`
    }
  })
    .then((res) => {
        console.log(res.headers) // <---- empty object
        // filename = res.headers.get('Content-Disposition').split(";")[1]
        return res.blob()})
    .then((blob) => {
      const file = window.URL.createObjectURL(blob);
      const a = document.createElement('a');
      a.href = file;
      a.download = filename;
      document.body.appendChild(a); 
      a.click();
      a.remove();
    });
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Was able to resolve this issue. There was a header missing from the server response.

response["Access-Control-Expose-Headers"] = "Content-Disposition"

Adding this header in the response started exposing the missing filename.

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