transformer-proxy icon indicating copy to clipboard operation
transformer-proxy copied to clipboard

Print POST body request before transform the response, how ?

Open droidrcc opened this issue 7 years ago • 0 comments

It is possible to print the POST body request before to transform the response ?

var http = require('http'),
	connect = require('connect'),
	httpProxy = require('http-proxy'),
	transformerProxy = require('transformer-proxy');

var transformerFunction = function (data, req, res) {
	/*var json = convert.xml2json(data, {compact: true, spaces: 4});*/
	return data;
};

var app = connect();
var proxy = httpProxy.createProxyServer({
	target: 'https://localhost:9000',
	secure: false
});

proxy.on('proxyReq', function(proxyReq, req, res, options) {
  console.log("proxyReq:", proxyReq);
});

app.use(transformerProxy(transformerFunction));

app.use(function (req, res) {
	proxy.web(req, res);
});

http.createServer(app).listen(8000);

Thanks, D

droidrcc avatar Mar 09 '18 11:03 droidrcc