0

I am creating an react app using create-react-app for school management system. I had used node js for creating api end point. I am able to store student detail and can fetch it back to display in react. I had created an endpoint for uploading student images, which is also working perfect. I had stored the image on node js server public folder. I know it should be on client public folder but if another application for example android or angular or vue application tries to call the same image will not get as it will be stored in react public folder.

So how could I solve the image problem?

2
  • 2
    You need a route that serves static files from node.js assuming you are using express you can use - expressjs.com/en/starter/static-files.html Your endpoint need to serve images as static files from a folder on your server Commented Jan 2, 2020 at 12:28
  • 1
    store it on server. pass url to image as value to src element of image Commented Jan 2, 2020 at 12:43

1 Answer 1

1

You've done all the logic right, just add image URL to user profile, for example :

imageUrl: 'https://{your API URL}'

or the better way to upload all images on file server like S3 or Google Cloud Storage, and save only link to image on user profile

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.