You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In config/http.js, uncomment example middleware config (at minimum the middleware: { property and closing }, and the bodyParser: require('skipper') line.
sails lift
Make any request (e.g. to the homepage) and notice that the request hangs.
The issue is that in defaults.js in the HTTP hook code we go to great lengths to allow overriding of the body parser via sails.config.http.middleware.bodyParser, but since all of that code is wrapped in _.defaults(), the result of the self-calling function is never actually used, because a value already exists for the bodyParser key. In the example above, the loaded body parser would be the result of require('skipper'), which is not itself valid (it needs to be called w/ options). Furthermore, doing:
bodyParser: require('skipper')(<some options>)
doesn't work, because the self-calling function in defaults.js would then call that resulting function, resulting in an error.
Currently the only way to customize the bodyParser is via sails.config.http.bodyParser (not middleware.bodyParser). We should probably keep this for backwards-compatibility (with a deprecation warning), but in the self-calling function in defaults.js, just return early if sails.config.http.middleware.bodyParser is defined.
The text was updated successfully, but these errors were encountered:
To reproduce:
config/http.js
, uncomment example middleware config (at minimum themiddleware: {
property and closing}
, and thebodyParser: require('skipper')
line.sails lift
The issue is that in
defaults.js
in the HTTP hook code we go to great lengths to allow overriding of the body parser viasails.config.http.middleware.bodyParser
, but since all of that code is wrapped in_.defaults()
, the result of the self-calling function is never actually used, because a value already exists for thebodyParser
key. In the example above, the loaded body parser would be the result ofrequire('skipper')
, which is not itself valid (it needs to be called w/ options). Furthermore, doing:doesn't work, because the self-calling function in
defaults.js
would then call that resulting function, resulting in an error.Currently the only way to customize the bodyParser is via
sails.config.http.bodyParser
(notmiddleware.bodyParser
). We should probably keep this for backwards-compatibility (with a deprecation warning), but in the self-calling function indefaults.js
, just return early ifsails.config.http.middleware.bodyParser
is defined.The text was updated successfully, but these errors were encountered: