The question is simple, but I cannot find a solution that will work when tested against Passport.
Let's say I have a callback route like https://localhost/auth/google/callback
Right now I'm getting a stack trace if I throw garbage parameters here that then shows information like directory structures, etc, which is obviously not appropriate. I cannot blindly depend on every new route to handle errors appropriately.
Is there any way for me to disable a stack trace response given ANY error in NodeJS?
I tried the following:
app.use((err, req, res, next) => {
if (! err) {
return next();
}
res.status(500);
res.send('500: Internal server error');
});
And this did not work for TokenError: Code was already redeemed. used in PassportJS.
Is this even possible? Obviously this would be for a production environment only.
You need to set NODE_ENV to production to disable stacktrace, you can change it as an enviroment variable.
set NODE_ENV=production
Or if it's inconvenient do it in the program itself like this:
process.env.NODE_ENV = 'production';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With