Open ayyappaappana opened 8 years ago
This behaviour is due to lines 34 to 36 of the file api/response/serverError.js
if (sails.config.environment === 'production' && sails.config.keepResponseErrors !== true) { data = undefined; }
Meaning that data passed to the function are simply destroyed on production. Other responses have the same behaviour.
The solution is to set the keepResponseErrors to true in a config file.
To my mind this behaviour is indeed confusing when one wants to pass custom error message with the response, and makes this "bug" very hard to find for a beginner. Documentation should be a bit clearer about this.
Hi All,
Some kind of confusion, there is no keywords like res.serverError, res.BadRequest, is working in productions mode.
My configuarations are something like :
sails-auth : 1.3.1 sails-permissions : 1.4.2
sails.services.passport.protocols.local.register(req.body, function (err, user) { //if (err) return res.status(500).send(err); if (err) return res.serverError(err); res.ok(user); });
on the above code of user controller: I am trying to run command like
sails lift (Development Mode) It is throwing error. with internal server error(500) with validation hook messages.
Not Working: Sails lift --prod(Production Mode) It is throwing 500 internal server error, with no error object. I dont know what would be cause with this and console is printing something like this.
Invalid attributes sent to User: firstName
undefined
should be a string (instead of "null", which is a object) "required" validation rule failed for input: null , reason: 'NaN attributes are invalid', code: 'E_VALIDATION', status: 400, invalidAttributes: { firstName: [ [Object], [Object] ] } }By default, the specified error (err) will be excluded if the app is running in the "production" environment (i.e. process.env.NODE_ENV === 'production').
how to override for production mode please help me on this,,