From ab5c7d56360e9bf288a1805e23b83d0695a8da2a Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 11 May 2024 23:16:50 +0300 Subject: [PATCH] #12: Fix asset path --- server/src/routes/assets.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/server/src/routes/assets.ts b/server/src/routes/assets.ts index 96339685f..5a12347dd 100644 --- a/server/src/routes/assets.ts +++ b/server/src/routes/assets.ts @@ -3,6 +3,7 @@ import path = require("path"); import express = require("express"); import env = require('../services/env'); import serveStatic = require('serve-static'); +import utils = require('../services/utils'); const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOptions>>) => { if (!env.isDev()) { @@ -15,9 +16,16 @@ const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOp }; function register(app: express.Application) { - const root = path.join(__dirname, '..', '..', '..'); + let root: string; + if (!utils.isElectron()) { + root = path.join(__dirname, '..', '..', '..'); + } else { + root = path.join(__dirname, '..', '..', '..', '..', '..'); + } + + console.log("Asset root path is", path.resolve(root)); const clientRoot = path.join(root, 'client'); - const commonRoot = path.join(root, 'common'); + const commonRoot = path.join(root, 'common'); app.use(`/${assetPath}/app`, persistentCacheStatic(path.join(clientRoot, 'src'))); app.use(`/${assetPath}/app-dist`, persistentCacheStatic(path.join(clientRoot, 'src-dist')));