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

293
Visualizações
How to fix net::ERR_ABORTED 404 (Not Found) when callink api route using next/link in NextJS

I have created an api route to download a CSV file and I am getting this error when using Next Link. I cannot just switch to because then my application will not build, so my hands are tied. The component is simple

const DownloadCsvPage = () => {
  return (
    <section className="w-full h-screen grid place-content-center">
      <Link href="/api/db-to-csv">
        <a className="px-20 py-9 border text-black no-underline">
          Download CSV
        </a>
      </Link>
    </section>
  );
};

I tried to follow this article https://www.loudnoises.us/solving-next-static-pages-js-404-not-found/ but setting href to current page path and as to the path of api route only appended the api routes url to the localhost but that did not trigger the download. Like

   <Link href="/download" as="/api/db-to-csv">
        <a className="px-20 py-9 border text-black no-underline">
          Download CSV
        </a>
      </Link>

After reading this solution https://exerror.com/js-file-gets-a-neterr_aborted-404-not-found/ i thought that moving the file I want to download to the public folder would do the job but it did not. Thanks

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

If you want to call the API, its better to use normal div tag and add onClick event handler and attach a function to it which will call your API with the help of fetch or axios and in that function you can use .then(result) and .catch(error) method to handle the response for you API accordingly.

about 4 years ago · Santiago Gelvez 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