Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
Merge branch 'master' into next55
zadamdf7c08934484
diff --cc src/wwwindex 3643c0ea9c,c17ae0412e..e3a26de4dc--- a/src/www+++ b/src/www@@@ -38,24 -38,20 +38,32 @@@ if (!semver.satisfies(process.version,let httpServer;async function startTrilium() {- const usedPort = await port;- const usedHost = await host;+ /**+ * The intended behavior is to detect when a second instance is running, in that case open the old instance+ * instead of the new one. This is complicated by the fact that it is possible to run multiple instances of Trilium+ * if port and data dir is configured separately. This complication is the source of the following weird usage.+ *+ * The line below makes sure that the "second-instance" (process in window.js) is fired. Normally it returns a boolean+ * indicating whether another instance is running or not, but we ignore that and kill the app only based on the port conflict.+ *+ * A bit weird is that "second-instance" is triggered also on the valid usecases (different port/data dir) and+ * focuses the existing window. But the new process is start as well and will steal the focus too, it will win, because+ * its startup is slower than focusing the existing process/window. So in the end it works out without having+ * to do complex evaluation.+ */+ require("electron").app.requestSingleInstanceLock();- app.set('port', usedPort);- app.set('host', usedHost);+ app.set('port', port);+ app.set('host', host);+ // Check from config whether to trust reverse proxies to supply user IPs, hostnames and protocols+ if (config['Network']['trustedReverseProxy']) {+ if (config['Network']['trustedReverseProxy'] === true || config['Network']['trustedReverseProxy'].trim().length) {+ app.set('trust proxy', config['Network']['trustedReverseProxy'])+ }+ }+ log.info('Trusted reverse proxy: ' + app.get('trust proxy'))+if (config['Network']['https']) {if (!config['Network']['keyPath'] || !config['Network']['keyPath'].trim().length) {throw new Error("keyPath in config.ini is required when https=true, but it's empty");