From 106d5c72c96ea12347a32bd7a0fa772e383a8d49 Mon Sep 17 00:00:00 2001 From: Brian Seymour Date: Fri, 7 May 2021 14:50:50 -0500 Subject: [PATCH] fix json validation --- api/src/api/v2.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/api/src/api/v2.js b/api/src/api/v2.js index 478b107..639ce99 100644 --- a/api/src/api/v2.js +++ b/api/src/api/v2.js @@ -8,13 +8,11 @@ const package = require('../package') const logger = require('logplease').create('api/v2'); router.use((req, res, next) => { - if (['GET', 'HEAD', 'OPTIONS'].includes(req.method) || !req.body) { + if (['GET', 'HEAD', 'OPTIONS'].includes(req.method)) { return next(); } - try { - JSON.parse(req.body); - } catch (e) { + if (req.headers['content-type'] !== 'application/json') { return res .status(415) .send({