diff --git a/package.json b/package.json index 3469873f1f..4d1d66729a 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "rebuild-node": "yarn workspace loot-core rebuild", "lint": "eslint . --max-warnings 0", "lint:verbose": "DEBUG=eslint:cli-engine eslint . --max-warnings 0", + "install:server": "yarn workspaces focus actual-sync --production", "typecheck": "yarn tsc && tsc-strict", "jq": "./node_modules/node-jq/bin/jq", "prepare": "husky" diff --git a/packages/sync-server/src/load-config.js b/packages/sync-server/src/load-config.js index f87e2b6cc5..7f1a57c6d1 100644 --- a/packages/sync-server/src/load-config.js +++ b/packages/sync-server/src/load-config.js @@ -2,7 +2,9 @@ import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; import createDebug from 'debug'; +import { createRequire } from 'module'; +const require = createRequire(import.meta.url); const debug = createDebug('actual:config'); const debugSensitive = createDebug('actual-sensitive:config'); @@ -51,6 +53,14 @@ if (process.env.ACTUAL_CONFIG_PATH) { userConfig = parseJSON(configFile, true); } +const actualAppWebBuildPath = path.join( + // require.resolve is used to recursively search up the workspace to find the node_modules directory + path.dirname(require.resolve('@actual-app/web/package.json')), + 'build', +); + +debug(`Actual web build path: '${actualAppWebBuildPath}'`); + /** @type {Omit} */ let defaultConfig = { loginMethod: 'password', @@ -68,13 +78,7 @@ let defaultConfig = { trustedAuthProxies: null, port: 5006, hostname: '::', - webRoot: path.join( - projectRoot, - 'node_modules', - '@actual-app', - 'web', - 'build', - ), + webRoot: actualAppWebBuildPath, upload: { fileSizeSyncLimitMB: 20, syncEncryptedFileSizeLimitMB: 50,