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.
I have deployed my Website on Heroku. Could this issue be solved using pipeline in Heroku? How do i solve this issue ?
I want npm run build command to get executed in client folder every time the user reloads a website.
Root Folder Structure
client Folder Structure
Data in MongoDB Database
shashwat singh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.