A local-first personal finance app
Replace '\n' in key/cert text with literal newlines (#127)
Jed Foxc6c324323476
diff --git a/README.md b/README.mdindex afbba2bc38..b9ecf242a4 100644--- a/README.md+++ b/README.md@@ -72,8 +72,6 @@ Now we need to tell Actual to use this volume. Add this in `fly.toml`:That's it! Actual will automatically check if the `/data` directory exists and use it automatically.-_You can also configure the data dir with the `ACTUAL_USER_FILES` environment variable._-### One-click hosting solutions@@ -81,6 +79,10 @@ These are non-official methods of one-click solutions for running Actual. If you* PikaPods: [Run on PikaPods](https://www.pikapods.com/pods?run=actual)+## Configuring the server++The server accepts several configuration options, including for HTTPS certificates and various file paths. The documentation website has [a page dedicated to configuration options](https://actualbudget.github.io/docs/Installing/Configuration)+## Configuring the server URLThe Actual app is totally separate from the server. In this project, they happen to both be served by the same server, but the app doesn't know where the server lives.diff --git a/app.js b/app.jsindex d3e8a3f89a..b2f70aef89 100644--- a/app.js+++ b/app.js@@ -38,6 +38,13 @@ app.use(express.static(config.webRoot, { index: false }));app.get('/*', (req, res) => res.sendFile(config.webRoot + '/index.html'));+function parseHTTPSConfig(value) {+ if (value.startsWith('-----BEGIN')) {+ return value;+ }+ return fs.readFileSync(value);+}+async function run() {if (!fs.existsSync(config.serverFiles)) {fs.mkdirSync(config.serverFiles);@@ -54,12 +61,8 @@ async function run() {const https = require('https');const httpsOptions = {...config.https,- key: config.https.key.startsWith('-----BEGIN')- ? config.https.key- : fs.readFileSync(config.https.key),- cert: config.https.cert.startsWith('-----BEGIN')- ? config.https.cert- : fs.readFileSync(config.https.cert)+ key: parseHTTPSConfig(config.https.key),+ cert: parseHTTPSConfig(config.https.cert)};https.createServer(httpsOptions, app).listen(config.port, config.hostname);} else {diff --git a/load-config.js b/load-config.jsindex 51e1773ec8..68159591ec 100644--- a/load-config.js+++ b/load-config.js@@ -50,8 +50,8 @@ module.exports = {https:process.env.ACTUAL_HTTPS_KEY && process.env.ACTUAL_HTTPS_CERT? {- key: process.env.ACTUAL_HTTPS_KEY,- cert: process.env.ACTUAL_HTTPS_CERT,+ key: process.env.ACTUAL_HTTPS_KEY.replace(/\\n/g, '\n'),+ cert: process.env.ACTUAL_HTTPS_CERT.replace(/\\n/g, '\n'),...(config.https || {})}: config.https