I am trying to configure proxy middleware koa-proxy. It works fine for all GET requests but POST requests with body don't reach the actual API.
let koa = require('koa');
let staticServe = require('koa-static');
let bodyParser = require('koa-bodyparser');
let config = require('./config');
let proxy = require('koa-proxy')({ host: 'config.API_URL' });
let app = koa();
app.use(staticServe(config.staticPath));
app.use(bodyParser());
app.use(proxy);
app.listen(config.port);
console.log(`Listening on port ${config.port}`);
How should I configure it to be able to make all requests from the app to the localhost
which will be then directed to the API URL with the body and processed properly?
app.use(bodyParser())
?koa-proxy
internally usespipe
, so you don't need to parse the body unless you want log or use it. – zeronone