Webpack dev server proxy config documentation seen here:
https://webpack.js.org/configuration/dev-server/#devserver-proxy
says it uses http-proxy-middleware:
https://github.com/chimurai/http-proxy-middleware#http-proxy-events
Using the onProxyRes
function documented in the above link I do the following:
function onProxyRes(proxyRes, req, res) {
proxyRes.headers['x-added'] = 'foobar'; // add new header to response
delete proxyRes.headers['x-removed']; // remove header from response
console.log(req.headers) // log headers
console.log(req.body) // undefined
console.log(proxyReq.body) // undefined
}
My problem, although everything else works great - I cannot log the Request Body - it returns undefined
Anyone know how to read the request body for debugging purposes? Do I somehow need to use the npm body-parser
module? If so, how? thx