How do I turn off errors array in production mode? #2495
Unanswered
pquerner
asked this question in
Questions & Answers
Replies: 1 comment
-
|
@pquerner in NestJS, use the app.useGlobalPipes(
new ValidationPipe({
disableErrorMessages: process.env.NODE_ENV === 'production',
})
);this returns a 400 Bad Request with no constraint details in the response body when enabled. validation still runs and rejects invalid input, it just strips the error messages from the response. if you're not using NestJS, catch the validation errors and return a generic message: const errors = await validate(dto);
if (errors.length > 0) {
throw new HttpException('Validation failed', 400);
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
In production mode I'd like to give out no details about what went wrong with the validation.
How can I turn it off?
Validation should still take place, but I don't wish to give out any details about why it failed.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions