fix: 空json5

This commit is contained in:
手瓜一十雪
2025-01-27 19:30:45 +08:00
parent 8fc13f8a8f
commit da24ae7e1c

View File

@@ -59,12 +59,15 @@ export class OB11HttpServerAdapter extends IOB11NetworkAdapter<HttpServerConfig>
}); });
req.on('end', () => { req.on('end', () => {
try { try {
req.body = json5.parse(rawData); req.body = json5.parse(rawData || '{}');
next(); next();
} catch (err) { } catch (err) {
return res.status(400).send('Invalid JSON'); return res.status(400).send('Invalid JSON');
} }
}); });
req.on('error', (err) => {
return res.status(400).send('Invalid JSON');
});
}); });
this.app.use((req, res, next) => this.authorize(this.config.token, req, res, next)); this.app.use((req, res, next) => this.authorize(this.config.token, req, res, next));