0

I am developing a project using next js. In the project I have developed, I use an API to copy images under public/images. I noticed something like this. After compiling the project with the npm run build, the copying process is successful and the deletion process is also successful, but I cannot view the image on the screen. What could be the reason for this?

The second image named sss.kopyasi.png was uploaded after it was built and it does not appear on the screen, what could be the reason?

When I rebuild the project, the images are coming, I used the Img tag of NextJs and I used the normal img tag, the problem did not get fixed.

The second image named sss.kopyasi.png was uploaded after it was built and it does not appear on the screen, what could be the reason?

Yilmaz
  • 35,338
  • 10
  • 157
  • 202
Kubilay
  • 33
  • 5

1 Answers1

0

When you build, next.js creates a bundle and with npm run start next.js it serves that production build. so anything after the build process added to the application will not be shown. You have to re-build again. Regarding public folder, from here: from docs

Note: Only assets that are in the public directory at build time will be served by Next.js. Files added at runtime won't be available. We recommend using a third party service like AWS S3 for persistent file storage.

As far as I know, public folder is not copied but references are held in the production build. If you want to dynamically serve public files from public directory, another option is you need to opt out next server and create an express server using express static setting folder setting

Yilmaz
  • 35,338
  • 10
  • 157
  • 202