From 6d05039a96f67388b60932ed89b25b71b6bc612c Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Thu, 24 Aug 2017 23:15:57 +0200 Subject: proxy: Also copy Content-Type --- modules/proxy/proxy.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'modules/proxy') diff --git a/modules/proxy/proxy.js b/modules/proxy/proxy.js index 66c50df..e18ab6a 100644 --- a/modules/proxy/proxy.js +++ b/modules/proxy/proxy.js @@ -15,7 +15,7 @@ function fetch(method,url,cb){ var body=""; res.on("data",function(data){body+=data;}); res.on("end",function(){ - cb(res.statusCode,body); + cb({status: res.statusCode, headers: res.headers},body); }); }).on("error",function(){ cb(null,null); @@ -37,9 +37,16 @@ module.exports=function(app,io,moddir){ var id=req.params.id; var path="/"+req.path.split("/").slice(3).join("/"); if(iddict[id]){ - fetch(req.method,iddict[id]+path,function(status,body){ - if(status==null)res.status(500).send("An error occurred...\n"); - else res.status(status).send(body); + fetch(req.method,iddict[id]+path,function(obj,body){ + if(obj.status==null){ + res.status(500).send("An error occurred...\n"); + return; + } + res.status(obj.status); + if(obj.headers["content-type"]){ + res.set("Content-Type",obj.headers["content-type"]); + } + res.send(body); }); } else { res.status(404).send( -- cgit v1.2.3-70-g09d2