Ensure express server options are applied consistently

Fixes #4169
This commit is contained in:
Nick O'Leary
2023-05-22 10:54:37 +01:00
parent 55a9a29f76
commit 57359d1659
12 changed files with 62 additions and 44 deletions

View File

@@ -37,7 +37,6 @@ var adminApp;
var server;
var editor;
/**
* Initialise the module.
* @param {Object} settings The runtime settings
@@ -49,7 +48,7 @@ var editor;
function init(settings,_server,storage,runtimeAPI) {
server = _server;
if (settings.httpAdminRoot !== false) {
adminApp = express();
adminApp = apiUtil.createExpressApp(settings);
var cors = require('cors');
var corsHandler = cors({
@@ -64,14 +63,6 @@ function init(settings,_server,storage,runtimeAPI) {
}
}
var defaultServerSettings = {
"x-powered-by": false
}
var serverSettings = Object.assign({},defaultServerSettings,settings.httpServerOptions||{});
for (var eOption in serverSettings) {
adminApp.set(eOption, serverSettings[eOption]);
}
auth.init(settings,storage);
var maxApiRequestSize = settings.apiMaxLength || '5mb';
@@ -136,10 +127,11 @@ async function stop() {
editor.stop();
}
}
module.exports = {
init: init,
start: start,
stop: stop,
init,
start,
stop,
/**
* @memberof @node-red/editor-api