Files
MagicMirror/serveronly/index.js
T
Kristjan ESPERANTO df6170c596 refactor: centralize server port resolution (#4198)
I took a look at the last remaining FIXME comment in the code - the one
in `js/app.js` pointing to PR #673. It's from 2017 and was already
flagged as a hotfix back then.

The problem: `MM_PORT` got written into a global `global.mmPort` that
was then read inconsistently across the code - sometimes via the global,
sometimes straight from `process.env`, plus separate logic in
`defaults.js`. Three ways to get the same port.

I pulled this into a single `getServerPort()` helper (`MM_PORT` ->
`config.port` -> `8080`) and switched `app.js`, `defaults.js`,
`server.js`, `electron.js` and both serveronly files over to it. The
global is gone now.

Basically the behavior should be unchanged.
2026-07-08 00:52:17 +02:00

10 lines
410 B
JavaScript

const app = require("../js/app");
const Log = require("../js/logger");
const { getServerPort } = require("#server_functions");
app.start().then((config) => {
const bindAddress = config.address ? config.address : "localhost";
const httpType = config.useHttps ? "https" : "http";
Log.info(`\n>>> Ready to go! Please point your browser to: ${httpType}://${bindAddress}:${getServerPort(config)} <<<`);
});