The raspberry pi applications says MagicMirror is a nodejs application that uses the electron rendering engine. But I looked it up, and Electron is just a javascript rendering engine based on Chrome. MagicMirror just generates javascript, whcich renders a DomDocument tree, and that is rendered either in electron, or as I have experiemnted, in a browser.
app.js is a server file
You might see app.js, if you download the code for MagicMirror. It is for nodejs, a javascript execution engine, that in this case, runs a web server, that emits the code for a web browser. app.js is run by nodejs on the server, to start a HTTP listener, and serve .js files meant for browser.
You can run MagicMirror in serveronly mode. Change the config.js to accept requests from any source IP. Then point your browser to that server, on port 3000 (default, but changeable in config.js). And it will load a index.html and the some javascript files that renders the entire application in the browser.
You may wonder, if MagicMirror can run behind a reverse proxy. B/c you are a sadist like me, you may like to torture unsuspecting fools to hear their screams of despair, to task them to such torture. If you’re also like me, you want to limit their despair to only superficial pleas, to bolster your own ego. I took 2 days researching how to put MagicMirror serveronly behind a nginx reverse-proxy. So anymore than that, is beyond wholesome fun watching someone tear their hair out.
In /etc/nginx/conf.d/default.conf
1. forward to the MirrorMirror port with “proxy_pass”. I use a DNS name mm_serveronly on port 80. You may want to avoid DNS resolution by using host file entry
2. change the HTTP header “Host:” with the “rewrite” directive, so that the web server on other side, can understand the HTTP request as it expects it (not as part of a virtual path). It removes the “MagicMirror/” path out of the request.
3. Change any response from MagicMirror, and replace any URL, with one with “MagicMirror/” prepended. This is done with the “sub_filter” directive. It searches for text, and replacement.
location /MagicMirror/ { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-NginX-Proxy true; rewrite ^/MagicMirror(.*)$ $1 break; proxy_pass http://mm_serveronly:3000/; proxy_ssl_session_reuse off; proxy_set_header Host $http_host; proxy_cache_bypass $http_upgrade; proxy_redirect off; sub_filter_once off; sub_filter_types *; sub_filter "/socket.io/" "/MagicMirror/socket.io/"; sub_filter "socket.io`" "MagicMirror/socket.io`"; }
“sub_filter” will change the HTML and javascript in some HTML files
AND definitely in “js/socketclient.js” needs this line updated (which can be changed in config.js, but then it wouldn’t work both in and out of reverse proxy).
... this.socket = io(`/${this.moduleName}`, { path: `${base}MagicMirror/socket.io` }); ...
MagicMirror serveronly by default expects to run as the root application in a URL. config.js can change that, but then it only works in reverse proxy.
Please be a responsible senior developer and limit how much you want to torture junior developers, with searching thru code trying to figure out how to modify emitted code, to comply w reverse proxy.