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

170
Vistas
Next js serve static js files not working

I have this folder structure for my next.js project

/public
    |static
        -hello.png
    |sample
        -test.js
    |charting_libray
        |bundle
            -dist.js
    |hello.png

In my local environment

http://localhost:3000/static/hello.webp

http://localhost:3000/hello.webp

http://localhost:3000/static/sample/test.js

All of these works. This means JS, Image anything can be served from nested folders or directly from the public folder.

But when I build the project using next build command and deployed it to the production.

mydomain.com/static/hello.webp
    
mydomain.com/hello.webp
    
mydomain.com/static/sample/test.js

I have noticed only the images files can be accessed and the JS file returns 404.

My real-world use case is, inside a component I pass the path to a library like this

libraryPath: "/static/charting_library/" 

I can see a net::ERR_ABORTED 404 error in the prod env browser console. Somehow the library works even with this 404 error.

But I need to know the reason for this 404 error and need to fix in the code. Any help! Thanks in advance.

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