Skip to content

Node.js based forum software built for the modern web

fix: trust_proxy upgrade script writes to wrong config.json when started with --config (breaks Docker logins) (#14527)

Enes Uysal29f90de6406d
diff --git a/src/upgrades/4.14.3/trust_proxy.js b/src/upgrades/4.14.3/trust_proxy.js
index d51c3c2cae..18334d37b8 100644
--- a/src/upgrades/4.14.3/trust_proxy.js
+++ b/src/upgrades/4.14.3/trust_proxy.js
@@ -2,24 +2,26 @@
const fs = require('fs');
const path = require('path');
+const nconf = require('nconf');
module.exports = {
name: 'Backfill trust_proxy for upgraded installs',
timestamp: Date.UTC(2026, 6, 28),
method: async function () {
+ const pathToConfig = path.resolve(__dirname, '../../../', nconf.get('config') || 'config.json');
+
let configJSON;
- const pathToConfig = '../../../config.json';
try {
- configJSON = require(pathToConfig) || {};
+ configJSON = JSON.parse(await fs.promises.readFile(pathToConfig, 'utf8')) || {};
} catch (err) {
configJSON = {};
}
if (!Object.hasOwn(configJSON, 'trust_proxy')) {
- await fs.promises.writeFile(path.join(__dirname, pathToConfig), JSON.stringify({
+ await fs.promises.writeFile(pathToConfig, JSON.stringify({
...configJSON,
trust_proxy: true,
}, null, 4));
}
},
-};
\ No newline at end of file
+};
diff --git a/src/upgrades/4.14.4/trust_proxy_config_path.js b/src/upgrades/4.14.4/trust_proxy_config_path.js
new file mode 100644
index 0000000000..d29d9dd47d
--- /dev/null
+++ b/src/upgrades/4.14.4/trust_proxy_config_path.js
@@ -0,0 +1,27 @@
+'use strict';
+
+const fs = require('fs');
+const path = require('path');
+const nconf = require('nconf');
+
+module.exports = {
+ name: 'Backfill trust_proxy into the config file specified via --config',
+ timestamp: Date.UTC(2026, 6, 29),
+ method: async function () {
+ const pathToConfig = path.resolve(__dirname, '../../../', nconf.get('config') || 'config.json');
+
+ let configJSON;
+ try {
+ configJSON = JSON.parse(await fs.promises.readFile(pathToConfig, 'utf8')) || {};
+ } catch (err) {
+ configJSON = {};
+ }
+
+ if (!Object.hasOwn(configJSON, 'trust_proxy')) {
+ await fs.promises.writeFile(pathToConfig, JSON.stringify({
+ ...configJSON,
+ trust_proxy: true,
+ }, null, 4));
+ }
+ },
+};