Skip to content

Build your personal knowledge base with Trilium Notes

refactor(nx/client): set up proxy to client

Elian Doran659ccd856192
diff --git a/apps/server/.serve.env b/apps/server/.serve.env
index dbc02e34e4..5006a37650 100644
--- a/apps/server/.serve.env
+++ b/apps/server/.serve.env
@@ -1,2 +1,3 @@
TRILIUM_ENV=dev
-TRILIUM_DATA_DIR=./apps/server/data
\ No newline at end of file
+TRILIUM_DATA_DIR=./apps/server/data
+TRILIUM_PUBLIC_SERVER=http://localhost:4200
\ No newline at end of file
diff --git a/apps/server/src/routes/assets.ts b/apps/server/src/routes/assets.ts
index a8716de79f..685af90cb4 100644
--- a/apps/server/src/routes/assets.ts
+++ b/apps/server/src/routes/assets.ts
@@ -19,9 +19,10 @@ const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOp
async function register(app: express.Application) {
const srcRoot = path.join(path.dirname(fileURLToPath(import.meta.url)), "..");
if (isDev) {
+ const clientProxy = proxy(process.env.TRILIUM_PUBLIC_SERVER);
app.use(`/${assetPath}/app/doc_notes`, persistentCacheStatic(path.join(srcRoot, "public/app/doc_notes")));
- app.use(`/${assetPath}/app`, proxy("localhost:4200"));
- app.use(`/${assetPath}/app-dist`, proxy("localhost:4200"));
+ app.use(`/${assetPath}/app`, clientProxy);
+ app.use(`/${assetPath}/app-dist`, clientProxy);
app.use(`/${assetPath}/stylesheets`, persistentCacheStatic(path.join(srcRoot, "../../client/stylesheets")));
app.use(`/${assetPath}/libraries`, persistentCacheStatic(path.join(srcRoot, "../../client/libraries")));
} else {