Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ function App () {
*/
this.start = async function () {
const configObj = Utils.loadConfig();
config = configObj.fullConf;
global.config = configObj.fullConf;
const config = global.config;
Utils.checkConfigFile(configObj);

global.defaultModulesDir = config.defaultModulesDir;
Expand Down Expand Up @@ -245,7 +246,7 @@ function App () {

Log.log("Sockets connected & modules started ...");

return config;
return global.config;
};

/**
Expand Down
12 changes: 6 additions & 6 deletions js/server_functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async function cors (req, res) {
return res.status(400).send(url);
} else {
url = match[1];
if (typeof config !== "undefined") {
if (typeof global.config !== "undefined") {
if (config.hideConfigSecrets) {
url = replaceSecretPlaceholder(url);
}
Expand Down Expand Up @@ -144,15 +144,15 @@ function getVersion (req, res) {
function getUserAgent () {
const defaultUserAgent = `Mozilla/5.0 (Node.js ${Number(process.version.match(/^v(\d+\.\d+)/)[1])}) MagicMirror/${global.version}`;

if (typeof config === "undefined") {
if (typeof global.config === "undefined") {
return defaultUserAgent;
}

switch (typeof config.userAgent) {
switch (typeof global.config.userAgent) {
case "function":
return config.userAgent();
return global.config.userAgent();
case "string":
return config.userAgent;
return global.config.userAgent;
default:
return defaultUserAgent;
}
Expand All @@ -163,7 +163,7 @@ function getUserAgent () {
* @returns {object} environment variables key: values
*/
function getEnvVarsAsObj () {
const obj = { modulesDir: `${config.foreignModulesDir}`, defaultModulesDir: `${config.defaultModulesDir}`, customCss: `${config.customCss}` };
const obj = { modulesDir: `${global.config.foreignModulesDir}`, defaultModulesDir: `${global.config.defaultModulesDir}`, customCss: `${global.config.customCss}` };
if (process.env.MM_MODULES_DIR) {
obj.modulesDir = process.env.MM_MODULES_DIR.replace(`${global.root_path}/`, "");
}
Expand Down
Loading