From d7eabc3846513a7160ae181f6af1ae7c8352db05 Mon Sep 17 00:00:00 2001 From: chin Date: Tue, 26 Oct 2021 19:28:00 +0800 Subject: [PATCH] fix: resolve body in a request is empty when content-type is XML --- server.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/server.js b/server.js index e1c18f55..9985e219 100644 --- a/server.js +++ b/server.js @@ -22,24 +22,17 @@ require('dotenv').config() app.use(compress()); app.use(flash()); app.use(express.static('public')); -app.use(bodyParser.urlencoded({ +app.use(express.urlencoded({ extended: true })); -app.use(bodyParser.json()); -app.use(bodyParser.json({ +app.use(express.json()); +app.use(express.json({ "type": "application/fhir+json" })); -app.use(bodyParser.text({ - "type": "text/*" -})); -app.use(bodyParser.raw({ - "type": "multipart/related", - limit: "1000mb" -})); -app.use(bodyParser.raw({ - "type": "multipart/form-data", - limit: "1000mb" +app.use(express.text({ + "type": ["text/*", "/_xml", "xml", "+xml"] })); + app.use((err, req, res, next) => { // This check makes sure this is a JSON parsing issue, but it might be // coming from any middleware, not just body-parser: