- Notifications
You must be signed in to change notification settings - Fork 872
Closed
Labels
Description
Following this recipe: https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/modify-post.md, I expect to be able conditionally modify the POST body based on the proxy path. The encodeURIComponent portion of this script only works with objects that are one level deep.
How do I make this work with any object, no matter how many levels deep it might go, or just bypass the onProxyReq method entirely for other URL's I don't care about?
Setup
- body-parser: 1.15.1
- http-proxy-middleware: 0.15.2
- express: 4.13.4
proxy middleware configuration
const apiProxy = proxyMiddleware('/services', { target: config.serverUrl, changeOrigin: true, pathRewrite: { '^/services': '' }, onProxyReq: // just like the recipe linked above, but with a conditional check on proxy pathserver mounting
const app = express(); app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.json()); app.use(apiProxy); app.listen(3000);