Skip to content

Commit 80f56c6

Browse files
committed
Added custom error handler to avoid giving clients excess information on bad requests
1 parent 5ee9609 commit 80f56c6

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/backend/server.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ app.use(cors({
8989
credentials: true // allow cookies
9090
}));
9191

92+
// Custom Error Handler to minimize verbose output
93+
app.use((err, req, res, next) => {
94+
console.error(err);
95+
res.status(500).json({ error: 'An unexpected error occurred.' });
96+
});
97+
98+
// attempting to cover up digital foot-print
9299
app.disable('x-powered-by');
93100

94101
/*

0 commit comments

Comments
 (0)