fix(http): add malformed JSON syntax error handling middleware and update dist
CI / Build & Quality Check (push) Has been cancelled

This commit is contained in:
Amirul Islam Redwan71
2026-09-26 00:51:21 +06:00
parent 42cdaefd82
commit 0606928a09
18 changed files with 1032 additions and 288 deletions
+12
View File
@@ -48,6 +48,18 @@ function keysFromRequest(req: Request): EnvSource {
const app = express();
app.use(express.json({ limit: "1mb" }));
// Handle malformed JSON gracefully to prevent unhandled SyntaxErrors
app.use((err: any, req: Request, res: Response, next: express.NextFunction) => {
if (err instanceof SyntaxError && "body" in err) {
return res.status(400).json({
ok: false,
error: "Bad Request",
message: "Malformed JSON payload provided.",
});
}
next(err);
});
// Allow browser-based and cross-origin MCP clients.
app.use((req, res, next) => {
res.header("Access-Control-Allow-Origin", "*");