How to deploy React + Nodejs app to Heroku where in my server I'm saving the uploded images to the public folder of client i.e. React?

Viewed 65

Actually I've created a app where I've used React for client side and Nodejs for server side. I am created a createPost route in my server that uploads a file and saves it to the public folder of client side.

This is the function which is written inside a route of nodejs application in the server folder that saves the image to client folder:

const myPath =  path.join(__dirname, `../../client/public/images/${name}`);
file.mv(`${myPath}`,err => {
    if(err) {
        return res.status(500).send(err);
    }
});

And hence I'm using those images in my index.html present in public folder of client side.

Now, I am not able to deploy it to Heroku because I'm saving my images to client folder but after React app is build, then how will it proceed to save those images in the build folder.

0 Answers
Related