I'm trying to Fetch a URL (http://localhost) that will return a picture (At this moment, the extension doesn't matter) through HTTP using Node.js.
Front End
let image = await fetch('http://localhost:3031', {
mode: 'cors',
method: 'GET'
})
Back End
var http = require('http');
var fs = require('fs');
http.createServer(function (req, res) {
res.setHeader('Content-Type', 'image/png');
fs.readFile('image.png', (err, data) => {
res.write(data, "binary");
res.end();
});
}).listen(3031)
I want to take that picture and then display it into the Website.
Im getting the file, NOT THE SRC