From d1bfa435bcf2c7ae82e594977193236212c9d38d Mon Sep 17 00:00:00 2001 From: Bartol Karuza Date: Wed, 23 Dec 2015 14:44:56 +0100 Subject: [PATCH 1/2] Added logging of proxy requests if options.log --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index 2434ebb..8c3af44 100644 --- a/index.js +++ b/index.js @@ -35,6 +35,10 @@ module.exports = function(options) { method: this.method, body: parsedBody }; + // Log outgoing requests + if(options.log) { + console.log('proxying request: ', opt); + } // set 'Host' header to options.host (without protocol prefix) if (options.host) opt.headers.host = options.host.slice(options.host.indexOf('://')+3) From 4a7889b20ee9ed28c07bdedf821e3b12fb999b7c Mon Sep 17 00:00:00 2001 From: Bartol Karuza Date: Wed, 23 Dec 2015 15:05:36 +0100 Subject: [PATCH 2/2] updated doc for PR --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 376707f..94cbdfe 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,15 @@ app.use(proxy({ })); ``` +You can turn on logging for the requests that are about to be proxied. This outputs the request details of the request going to the proxy target. + +``` +app.use(proxy({ + host: 'http://alicdn.com', // proxy alicdn.com... + log: true // turn logging on +})); +``` + ## LICENSE Copyright (c) 2014 popomore. Licensed under the MIT license.