Real time dynamic images folder problem
Answered
Idra posted this in #help-forum
IdraOP
Hi everyone! I'm working on an image-based platform. Everything works fine until I switch to production.
In production, when a user creates an image, the image gets uploaded through my custom Next.js 13 API route and is stored in a folder located in "public/uploads".
It works! However, the image doesn't appear to the user on the website until I rebuild the entire website. I'm using Next-Image to display the image, but regardless of the configuration I have, the image doesn't show up, so i can't show real-time images.
I was thinking: could I upload these images to a different folder so that I don't need to rebuild the entire website?
Can someone help me?
Thanks!
In production, when a user creates an image, the image gets uploaded through my custom Next.js 13 API route and is stored in a folder located in "public/uploads".
It works! However, the image doesn't appear to the user on the website until I rebuild the entire website. I'm using Next-Image to display the image, but regardless of the configuration I have, the image doesn't show up, so i can't show real-time images.
I was thinking: could I upload these images to a different folder so that I don't need to rebuild the entire website?
Can someone help me?
Thanks!
Answered by joulev
you cannot save it in
public, the content of public is taken during build and further writes into the folder are ignored6 Replies
IdraOP
Up
Do you get a bad response in the network tab in the google console?
@Idra Hi everyone! I'm working on an image-based platform. Everything works fine until I switch to production.
In production, when a user creates an image, the image gets uploaded through my custom Next.js 13 API route and is stored in a folder located in "public/uploads".
It works! However, the image doesn't appear to the user on the website until I rebuild the entire website. I'm using Next-Image to display the image, but regardless of the configuration I have, the image doesn't show up, so i can't show real-time images.
I was thinking: could I upload these images to a different folder so that I don't need to rebuild the entire website?
Can someone help me?
Thanks!
you cannot save it in
public, the content of public is taken during build and further writes into the folder are ignoredAnswer
you need to save it elsewhere
if you host it on vercel, you need to use object storage services
if you host it in a normal server, save it elsewhere and read it with
if you host it on vercel, you need to use object storage services
if you host it in a normal server, save it elsewhere and read it with
fs