From 9f55069aa4bdeefb32db14e8cd0992eb6425ba0f Mon Sep 17 00:00:00 2001 From: baozhoutao Date: Mon, 7 Feb 2022 11:11:37 +0800 Subject: [PATCH] =?UTF-8?q?fix=20bug=EF=BC=9A=E6=9F=A5=E8=AF=A2=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E5=99=A8=E4=B8=8D=E6=98=BE=E7=A4=BA=20#2753?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/service-charts/package.service.js | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/services/service-charts/package.service.js b/services/service-charts/package.service.js index 4585423430..79a3e061b1 100644 --- a/services/service-charts/package.service.js +++ b/services/service-charts/package.service.js @@ -328,16 +328,22 @@ module.exports = { if (this.settings.initBuilderRouter) { return; } - const router = express.Router(); - let publicPath = require.resolve("@steedos/service-charts/package.json"); - publicPath = publicPath.replace("package.json", 'webapp'); - let routerPath = ""; - if (__meteor_runtime_config__.ROOT_URL_PATH_PREFIX) { - routerPath = __meteor_runtime_config__.ROOT_URL_PATH_PREFIX; + this.settings.initBuilderRouter = true; + try { + const router = express.Router(); + let publicPath = require.resolve("@steedos/service-charts/package.json"); + publicPath = publicPath.replace("package.json", 'webapp'); + let routerPath = ""; + if (__meteor_runtime_config__.ROOT_URL_PATH_PREFIX) { + routerPath = __meteor_runtime_config__.ROOT_URL_PATH_PREFIX; + } + const cacheTime = 86400000 * 1; // one day + router.use(`${routerPath}/builder`, express.static(publicPath, { maxAge: cacheTime })); + WebApp.rawConnectHandlers.use(router); + } catch (error) { + console.error(error) + this.settings.initBuilderRouter = false; } - const cacheTime = 86400000 * 1; // one day - router.use(`${routerPath}/builder`, express.static(publicPath, { maxAge: cacheTime })); - WebApp.rawConnectHandlers.use(router); } }, getDataSourceType: {