Skip to content

Commit

Permalink
Add important note about 'body-parser'
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sebastienroul authored and monkpow committed Jul 20, 2020
1 parent 7358c01 commit 1983acc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ function selectProxyHost() {

app.use('/', proxy(selectProxyHost));
```
### Middleware mixing

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.

```
app.use('/proxy', 'http://foo.bar.com')
// Declare use of body-parser AFTER the use of proxy
app.use(bodyParser.foo(bar))
app.use('/api', ...)
```

### Options

Expand Down

0 comments on commit 1983acc

Please sign in to comment.