Yes you can encode your base64 string and return it to the client as an image:
server.get("/api/id/:w", function(req, res) {
var data = getIcon(req.params.w);
var img = Buffer.from(data, 'base64');
res.writeHead(200, {
'Content-Type': 'image/png',
'Content-Length': img.length
});
res.end(img);
});