Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print POST body request before transform the response, how ? #12

Open
droidrcc opened this issue Mar 9, 2018 · 0 comments
Open

Print POST body request before transform the response, how ? #12

droidrcc opened this issue Mar 9, 2018 · 0 comments

Comments

@droidrcc
Copy link

droidrcc commented Mar 9, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant