-
Notifications
You must be signed in to change notification settings - Fork 45
Closed
Description
I test koa proxies in my project, I find a weird bug when it works with koa-bodyparser
.
// this works well.
const Koa = require('koa');
const app = new Koa();
const proxy = require('koa-proxies')
const bodyParser = require('koa-bodyparser');
app.use(proxy('/user', {
target: 'http://example.com',
changeOrigin: true,
rewrite: path => path
}))
app.use(bodyParser())
app.listen(8080);
// this works with bug "socket hang up".
const Koa = require('koa');
const app = new Koa();
const proxy = require('koa-proxies')
const bodyParser = require('koa-bodyparser');
app.use(bodyParser())
app.use(proxy('/user', {
target: 'http://example.com',
changeOrigin: true,
rewrite: path => path
}))
app.listen(8080);
the only difference is the sequence of the bodyParser and proxy.
I guess the post data will be consumed by the bodyParser, that is not what we want and will not proxy to our target, so it should be placed behind the proxy.
It will save our time if document it. Thank you.
ibilichenko
Metadata
Metadata
Assignees
Labels
No labels