fix json validation
This commit is contained in:
parent
3ea6ca1180
commit
106d5c72c9
|
@ -8,13 +8,11 @@ const package = require('../package')
|
||||||
const logger = require('logplease').create('api/v2');
|
const logger = require('logplease').create('api/v2');
|
||||||
|
|
||||||
router.use((req, res, next) => {
|
router.use((req, res, next) => {
|
||||||
if (['GET', 'HEAD', 'OPTIONS'].includes(req.method) || !req.body) {
|
if (['GET', 'HEAD', 'OPTIONS'].includes(req.method)) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (req.headers['content-type'] !== 'application/json') {
|
||||||
JSON.parse(req.body);
|
|
||||||
} catch (e) {
|
|
||||||
return res
|
return res
|
||||||
.status(415)
|
.status(415)
|
||||||
.send({
|
.send({
|
||||||
|
|
Loading…
Reference in New Issue