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

295
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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