feat: Make web app path static for the backend
This commit is contained in:
@@ -1,19 +1,19 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { dirname, join } from 'path';
|
import path, { join } from 'path';
|
||||||
import appConfig from '../config/app.js';
|
import appConfig from '../config/app.js';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
const webUIHandler = async (app) => {
|
const webUIHandler = async (app) => {
|
||||||
if (appConfig.serveWebAppSeparately) return;
|
if (appConfig.serveWebAppSeparately) return;
|
||||||
|
|
||||||
const moduleURL = new URL('@automatisch/web/package.json', import.meta.url);
|
const webAppPath = join(__dirname, '../../../web/');
|
||||||
const modulePath = fileURLToPath(moduleURL);
|
const webBuildPath = join(webAppPath, 'build');
|
||||||
const webAppPath = dirname(modulePath);
|
const indexHtml = join(webAppPath, 'build', 'index.html');
|
||||||
|
|
||||||
const webBuildPath = join(dirname(webAppPath), 'build');
|
|
||||||
const indexHtml = join(dirname(webAppPath), 'build', 'index.html');
|
|
||||||
|
|
||||||
app.use(express.static(webBuildPath));
|
app.use(express.static(webBuildPath));
|
||||||
|
|
||||||
app.get('*', (_req, res) => {
|
app.get('*', (_req, res) => {
|
||||||
res.set('Content-Security-Policy', 'frame-ancestors: none;');
|
res.set('Content-Security-Policy', 'frame-ancestors: none;');
|
||||||
res.set('X-Frame-Options', 'DENY');
|
res.set('X-Frame-Options', 'DENY');
|
||||||
|
Reference in New Issue
Block a user