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

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