问题
In my app (sails 0.12.0) I want to extend a limit of bytes send upon POST request. So in my config/http.js
I am uncommenting bodyParser
and set it to:
module.exports.http = {
...
middleware: {
...
bodyParser: (function () {
var opts = {limit: 1024*1024*5}; // set it to 5 megabytes
var fn;
// Default to built-in bodyParser:
fn = require('skipper');
return fn(opts);
})()
...
}
...
}
But now each my request seems to hang and in result I get 502 bad gateway
in every request sent from browser.
So:
- how do I initialize correctly
skipper
and extend allowed bytes limit? - why all my request now ends up with 502?
EDIT as @sgress454 inquired about where exactly bodyParser
is located I'have decided to precise it in initial question. In short it was located just where it is commented out in default config - under middleware
object.
It turns out it's a bug and the issue has been created, so please follow it for further development.
回答1:
The bug as has not been updated, but this now works for me in Sails 1.2.3.
Specifically, using the example bodyParser
in the default config/http.js
:
...
bodyParser: (function _configureBodyParser(){
var skipper = require('skipper');
var middlewareFn = skipper({
// strict: true,
limit: '10mb',
});
return middlewareFn;
})(),
...
Note that the original question was missing ()
in the bodyParser
definition.
来源:https://stackoverflow.com/questions/35548287/sails-increase-bodyparser-limits