Skip to content
This repository has been archived by the owner on Apr 24, 2019. It is now read-only.

Optional logging of proxy request added #21

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pass a logger will be good for me.

logger: console

}));
```

## LICENSE

Copyright (c) 2014 popomore. Licensed under the MIT license.
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down