ensure body-parser middleware is further downstream than rewrite.. fixes #30.

This commit is contained in:
Lloyd Brookes
2016-02-20 16:11:12 +00:00
parent 49dc789850
commit f7ecc9f5fd
5 changed files with 94 additions and 58 deletions

View File

@ -84,9 +84,6 @@ function localWebServer (options) {
/* pretty print JSON */
app.use(json())
/* request body parser */
app.use(bodyParser())
/* rewrite rules */
if (options.rewrite && options.rewrite.length) {
options.rewrite.forEach(route => {
@ -104,6 +101,9 @@ function localWebServer (options) {
})
}
/* must come after rewrite. See https://github.com/nodejitsu/node-http-proxy/issues/180. */
app.use(bodyParser())
/* path blacklist */
if (options.forbid.length) {
debug('forbid', options.forbid.join(', '))

View File

@ -50,6 +50,7 @@ function proxyRequest (route, app) {
proxy.once('proxyReq', function (proxyReq) {
proxyReq.path = url.parse(route.new).path
})
proxy.web(this.req, this.res, { target: route.new })
}
}