I'm using node-http-proxy
to try and proxy a request in my node/express web server. I'm attempting to append a body to a particular request at the route level, but the response I'm getting is indicating that the req.body
doesn't exist.
const proxy = httpProxy.createProxyServer({
changeOrigin: true,
target: process.env.API_URL,
port: 80
});
server.post('/api/login_check', (req, res) => {
req.url = req.url.replace('/api', '');
req.headers['Content-Type'] = 'application/json';
req.headers['accept'] = 'application/json';
req.body = JSON.stringify({
username: process.env.USERNAME,
password: process.env.PASSWORD
});
proxy.web(req, res);
});
Is this possible to do at the route level with node-http-proxy
?