Skip to content

Commit a530d14

Browse files
brandon-leapyearmonkpow
authored andcommitted
Update README
1 parent 0d5bf43 commit a530d14

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

README.md

+15-3
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,27 @@ app.use('/', proxy(selectProxyHost));
7777

7878
If you use 'https://www.npmjs.com/package/body-parser' you should declare it AFTER the proxy configuration, otherwise original 'POST' body could be modified and not proxied correctly.
7979

80-
```
81-
82-
app.use('/proxy', 'http://foo.bar.com')
80+
```js
81+
app.use('/proxy', proxy('http://foo.bar.com'))
8382

8483
// Declare use of body-parser AFTER the use of proxy
8584
app.use(bodyParser.foo(bar))
8685
app.use('/api', ...)
8786
```
8887

88+
If this cannot be avoided and you MUST proxy after `body-parser` has been registered, set `parseReqBody` to `false` and explicitly specify the body you wish to send in `proxyReqBodyDecorator`.
89+
90+
```js
91+
app.use(bodyParser.foo(bar))
92+
93+
app.use('/proxy', proxy('http://foo.bar.com', {
94+
parseReqBody: false,
95+
proxyReqBodyDecorator: function () {
96+
97+
},
98+
}))
99+
```
100+
89101
### Options
90102

91103
#### proxyReqPathResolver (supports Promises)

0 commit comments

Comments
 (0)