Skip to content

Commit 1983acc

Browse files
sebastienroulmonkpow
authored andcommitted
Add important note about 'body-parser'
I spent 2 days to find my issue. It was very hard to find the problem, but in some case, the body-parser change the body POST, and thn this body post is not sent to the target correctly. Hope it helps
1 parent 7358c01 commit 1983acc

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ function selectProxyHost() {
7272

7373
app.use('/', proxy(selectProxyHost));
7474
```
75+
### Middleware mixing
76+
77+
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.
78+
79+
```
80+
81+
app.use('/proxy', 'http://foo.bar.com')
82+
83+
// Declare use of body-parser AFTER the use of proxy
84+
app.use(bodyParser.foo(bar))
85+
app.use('/api', ...)
86+
```
7587

7688
### Options
7789

0 commit comments

Comments
 (0)