Tuesday 20 March 2018

Serving images from an express app to a frontend.

Hi,I am building a little VUE.js app and using a decoupled NODE.js/Express backend.I have a user profile where the user can upload images, which I achieve with Multer.This works great but now I need to server those images, currently I am making a request to get the users details and then I also get the path to the image but the problem is that the client is served on http://localhost:8080/ whilst my Restful API runs on http://localhost:8081.Any idea how I can actually serve the image on my front end?I can do a fetch request to the absolute url and then convert the file to base64 but does not feel like the right way to go about it.I have my static folder on Express setup, so a get request to the image works but how do I convert that to a usable image url?Thanks!

Submitted March 20, 2018 at 08:28PM by sieg_webdev

No comments:

Post a Comment