diff --git a/lib/runtimeSettings.js b/lib/runtimeSettings.js index 3abdbe9..02149d8 100644 --- a/lib/runtimeSettings.js +++ b/lib/runtimeSettings.js @@ -1,4 +1,5 @@ const path = require('path') +const bytes = require('bytes') function getSettingsFile (settings) { const projectSettings = { credentialSecret: '', @@ -71,6 +72,13 @@ function getSettingsFile (settings) { } else if (!authMiddlewareRequired && settings.settings.dashboardIFrame) { dashboardSettings.push('middleware: [ DashboardIFrameMiddleware ]') } + if (settings.settings.apiMaxLength) { + try { + dashboardSettings.push(`maxHttpBufferSize: ${bytes(settings.settings.apiMaxLength)}`) + } catch (err) { + // failed to parse + } + } projectSettings.dashboardUI = `ui: { ${dashboardSettings.join(', ')}},` } if (settings.settings.disableEditor !== undefined) { diff --git a/package-lock.json b/package-lock.json index a12cace..5332a47 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "@flowfuse/nr-project-nodes": "^0.7.4", "@node-red/util": "^3.1.0", "body-parser": "^1.20.2", + "bytes": "^3.1.2", "command-line-args": "^5.2.1", "express": "^4.21.0", "express-session": "^1.18.0", diff --git a/package.json b/package.json index da07849..0eb86b9 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "@flowfuse/nr-project-nodes": "^0.7.4", "@node-red/util": "^3.1.0", "body-parser": "^1.20.2", + "bytes": "^3.1.2", "command-line-args": "^5.2.1", "express": "^4.21.0", "express-session": "^1.18.0", diff --git a/test/unit/lib/runtimeSettings_spec.js b/test/unit/lib/runtimeSettings_spec.js index 027589b..b2b2801 100644 --- a/test/unit/lib/runtimeSettings_spec.js +++ b/test/unit/lib/runtimeSettings_spec.js @@ -135,7 +135,7 @@ describe('Runtime Settings', function () { const settings = await loadSettings(result) settings.should.have.property('credentialSecret', 'foo') settings.should.have.property('httpAdminRoot', '/red') - settings.should.have.property('ui', { path: '/dash' }) + settings.should.have.property('ui', { path: '/dash', maxHttpBufferSize: 123 }) settings.should.have.property('disableEditor', true) settings.should.have.property('apiMaxLength', '123') settings.should.have.property('debugMaxLength', 456)