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
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user