Skip to content

Node.js based forum software built for the modern web

feat: #7760, body-parser config

Barış Soner Uşaklı5de6d8857a81
diff --git a/src/webserver.js b/src/webserver.js
index 39d627877d..54e09e5424 100644
--- a/src/webserver.js
+++ b/src/webserver.js
@@ -143,8 +143,8 @@ function setupExpressApp(app) {
app.use(relativePath + '/apple-touch-icon', middleware.routeTouchIcon);
- app.use(bodyParser.urlencoded({ extended: true }));
- app.use(bodyParser.json());
+ configureBodyParser(app);
+
app.use(cookieParser());
const userAgentMiddleware = useragent.express();
app.use(function userAgent(req, res, next) {
@@ -192,6 +192,17 @@ function setupFavicon(app) {
}
}
+function configureBodyParser(app) {
+ const urlencodedOpts = nconf.get('bodyParser:urlencoded') || {};
+ if (!urlencodedOpts.hasOwnProperty('extended')) {
+ urlencodedOpts.extended = true;
+ }
+ app.use(bodyParser.urlencoded(urlencodedOpts));
+
+ const jsonOpts = nconf.get('bodyParser:json') || {};
+ app.use(bodyParser.json(jsonOpts));
+}
+
function setupCookie() {
var ttl = meta.getSessionTTLSeconds() * 1000;