From c4a6c86a694c72e2e8a7ae69a3bc1e463829a1f0 Mon Sep 17 00:00:00 2001 From: Faruk AYDIN Date: Mon, 8 Jan 2024 18:36:36 +0100 Subject: [PATCH] feat: Make web app path static for the backend --- packages/backend/src/helpers/web-ui-handler.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/backend/src/helpers/web-ui-handler.js b/packages/backend/src/helpers/web-ui-handler.js index 4e849a24..c5bd4f35 100644 --- a/packages/backend/src/helpers/web-ui-handler.js +++ b/packages/backend/src/helpers/web-ui-handler.js @@ -1,19 +1,19 @@ import express from 'express'; -import { dirname, join } from 'path'; +import path, { join } from 'path'; import appConfig from '../config/app.js'; import { fileURLToPath } from 'url'; +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + const webUIHandler = async (app) => { if (appConfig.serveWebAppSeparately) return; - const moduleURL = new URL('@automatisch/web/package.json', import.meta.url); - const modulePath = fileURLToPath(moduleURL); - const webAppPath = dirname(modulePath); - - const webBuildPath = join(dirname(webAppPath), 'build'); - const indexHtml = join(dirname(webAppPath), 'build', 'index.html'); + const webAppPath = join(__dirname, '../../../web/'); + const webBuildPath = join(webAppPath, 'build'); + const indexHtml = join(webAppPath, 'build', 'index.html'); app.use(express.static(webBuildPath)); + app.get('*', (_req, res) => { res.set('Content-Security-Policy', 'frame-ancestors: none;'); res.set('X-Frame-Options', 'DENY');