Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!