Reputation: 12199
There is the following code:
var url = require('url');
var proxy = require('express-http-proxy');
var localConfig = require('./config.js');
var frontendRuntime = require('frontend-runtime')(localConfig);
var config = frontendRuntime.config;
var app = require('./lib/utils/devServer.js');
var bodyParser = require('body-parser');
app.use(bodyParser.json({limit: 10 * 1024 * 1024}));
app.use(bodyParser.raw({limit: 10 * 1024 * 1024}));
app.use(bodyParser.text({limit: 10 * 1024 * 1024}));
app.use(bodyParser.urlencoded({limit: 10 * 1024 * 1024, extended: true}));
app.use('/some-url', proxy(config.apiEndpointHost, {
forwardPath: function(req, res) {
return '/api2' + url.parse(req.url).path;
}
}));
app.listen(config.portProxy);
console.log('Server started');
As you can see I pass 'limit' parameter for bodyParser (I want uploading files), but it didn't work - when I'm trying to upload image with 1.5 Mb size I got the error: "stderr: Error: request entity too large". How can I fix it? Thanks!
Upvotes: 1
Views: 1179
Reputation: 21
According to this issue you don't need bodyParser
app.use('/some-url', proxy(config.apiEndpointHost, {
limit: 10 * 1024 * 1024,
forwardPath: function(req, res) {
return '/api2' + url.parse(req.url).path;
}
}));
Upvotes: 2