-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keep error data on production using an argument #3568
Conversation
@eric-burel agree completely, was actually just talking about this today. What do you think about this: Never send in production for
|
Thanks for your answer, I think that's a very good solution, better than passing an argument every time we want to keep response data in production. |
@eric-burel great to hear. If you wouldn't mind updating this PR to make the change to the "backlog" section of the roadmap (see https://github.com/balderdashy/sails/blob/master/CONTRIBUTING.md for more info) we can get this merged in |
That's done :) |
Sorry for the delay, merging this in to backlog now -- I think some work might have been done on it already, too. |
This is now resolved in Sails v1! (see http://sailsjs.com/upgrading) |
Hello,
I have been struggling with the fact that sails preconfigured responses are deleting the data passed as argument in production. Indeed, I use this argument to pass custom error messages to the frontend (angular).
This default behaviour seems reasonnable to me as it prevents beginner mistakes and security flaws, yet it is a bit tricky for a beginner. Documentation might be clearer about this point (it is said explicitely but too quickly for someone that begins using sails).
Today the only solution consists in changing the keepResponseErrors config options. This is not a good solution as it is too global. To my mind, we should be able to set this argument on every call, using the "options" argument.
It would preserve the sane default behaviour of sails, yet allow to pass end-user error messages along with the error response easily.
Implementation is easy, I slightly changed the code of serverError.js, notFound.js, badRequest.js and notFound.js, adding a line and using a variable :
var keepResponseErrors = sails.config.keepResponseErrors || (options && options.keepResponseErrors); if (sails.config.environment === 'production' && !keepResponseErrors) { data = undefined; }