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. 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)