Use Node's Express combined with request to proxy remote images, but the content returned is different from the content of the original image. It is garbled, but the chaos is inconsistent.
Key code:
var FurionImgHandler = function (req, res) { var url = req.url.split('/fimg/')[1]; var options = { url: url }; function callback (error, response, body) { if (!error && response.statusCode === 200) { var contentType = response.headers['content-type']; response.setEncoding('binary'); res.set('Content-Type', contentType); res.send(body); } } request.get(options, callback); };
Original picture:
Pictures returned after proxying:
Just add
encoding: null
and that’s itIt should be the passed Blob object. Try converting it.
If the image does not require storage or other operations, can't it be passed directly to the response through the pipe?
soonfy