diff options
| author | tomsmeding <tom.smeding@gmail.com> | 2017-08-24 23:15:57 +0200 | 
|---|---|---|
| committer | tomsmeding <tom.smeding@gmail.com> | 2017-08-24 23:15:57 +0200 | 
| commit | 6d05039a96f67388b60932ed89b25b71b6bc612c (patch) | |
| tree | be832180d7f3539fed098eba2b62ff8cd32726fd /modules | |
| parent | aa59a979fd44fb6d3036150e386099470e576323 (diff) | |
proxy: Also copy Content-Type
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/proxy/proxy.js | 15 | 
1 files changed, 11 insertions, 4 deletions
| 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( | 
