I deployed my MERN website on Heroku. I want to run “npm run build” command in client folder everytime someone loads my deployed website in a browser
I created a Quiz Website. It has an Admin Panel to upload questions with images which will later displayed to the user. Whenever Admin uploads an image, it will be stored in the public folder inside client folder (/client/public). The client folder is set up using create-react-app. The path of the image in /client/public will be stored in the MongoDB database. Whenever image is displayed to the user, it extract the image via path stored in the MongoDB database from /client/public. Everything is working fine in the local dev environment. In order to deploy my website on Heroku, i created build folder with command npm run build inside client. As soon as I run the command npm start in the root folder to test my website in the production environment, images are are not getting displayed to the user. After that i execute npm run build command in client again to create build folder again and then images are getting displayed perfectly to the user.