From 4684b3a3f3559b99b888ef72aabf605263c8456e Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 20 Dec 2020 12:08:47 -0800 Subject: [PATCH] fix: Server error when invalid JSON passed to API endpoint Fix is to ensure that the errorHandling middleware is mounted before the body parser so that it can catch and return an error response --- server/api/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/api/index.js b/server/api/index.js index 8fd0f9303..1b273afaf 100644 --- a/server/api/index.js +++ b/server/api/index.js @@ -31,13 +31,13 @@ const api = new Koa(); const router = new Router(); // middlewares +api.use(errorHandling()); api.use( bodyParser({ multipart: true, formidable: { maxFieldsSize: 10 * 1024 * 1024 }, }) ); -api.use(errorHandling()); api.use(methodOverride()); api.use(validation()); api.use(apiWrapper());