mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Imageblob only from allowed origin
This commit is contained in:
@@ -221,6 +221,9 @@ var Frontpage = {
|
||||
$("#mega-background").css("opacity", 1);
|
||||
$(".autocomplete").attr("placeholder", list[i]._id);
|
||||
},500);
|
||||
},
|
||||
error: function() {
|
||||
$(".autocomplete").attr("placeholder", list[i]._id);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1095,10 +1095,16 @@ function incrementToken(token) {
|
||||
|
||||
router.route('/api/imageblob').post(function(req, res) {
|
||||
var Jimp = require("jimp");
|
||||
var origin = req.get("origin").replace("https://", "").replace("http://", "");
|
||||
var allowed = ["client.localhost", "localhost", "zoff.me", "client.zoff.me", "zoff.no", "client.zoff.no"];
|
||||
if(allowed.indexOf(origin) < 0) {
|
||||
res.sendStatus(403);
|
||||
return;
|
||||
}
|
||||
Jimp.read('https://img.youtube.com/vi/' + req.body.id + '/mqdefault.jpg', function (err, image) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
res.send(404);
|
||||
res.sendStatus(404);
|
||||
return;
|
||||
}
|
||||
image.blur(50)
|
||||
|
||||
Reference in New Issue
Block a user