From 71bc95251c9b70883e15b65f4ca9175d3c8a7dd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Losada=20Hern=C3=A1ndez?= Date: Sun, 1 Feb 2026 21:31:21 +0100 Subject: [PATCH] stable in prod --- index.html | 9 ++------- server.js | 4 ++-- server/app.js | 22 ++++++---------------- 3 files changed, 10 insertions(+), 25 deletions(-) diff --git a/index.html b/index.html index bfe95b67e..306b4d8dc 100644 --- a/index.html +++ b/index.html @@ -2,18 +2,13 @@ - - + content="width=device-width, initial-scale=1, height=device-height, interactive-widget=resizes-visual" /> - + type="text/css" /> diff --git a/server.js b/server.js index 750716151..6d052a939 100644 --- a/server.js +++ b/server.js @@ -10,7 +10,7 @@ async function start() { if (!isProd) { vite = await createViteServer({ - server: { middlewareMode: true }, + server: { middlewareMode: 'html' }, appType: "custom", }); @@ -23,7 +23,7 @@ async function start() { const app = await createApp(vite); - const PORT = process.env.PORT || config.get("web_port") || 8000; + const PORT = process.env.PORT || config.get("web_port") || 3000; app.listen(PORT, () => { const reset = "\x1b[0m"; // Reset to default style const bright = "\x1b[1m"; // Bright (bold) style diff --git a/server/app.js b/server/app.js index 86c98bac8..3be8fb40c 100644 --- a/server/app.js +++ b/server/app.js @@ -542,12 +542,6 @@ export default async function createApp(vite) { return next(); })); - app.use((req, res, next) => { - console.log('Before SPA middleware:', req.originalUrl); - next(); - }); - - //Send rendered page app.use(asyncHandler(async (req, res, next)=>{ if(!req.route) return res.redirect('/'); // Catch-all for invalid routes @@ -559,7 +553,7 @@ export default async function createApp(vite) { //Render the page const renderPage = async (req, res)=>{ - console.log('renderpage'); + // Create configuration object const configuration = { local : isLocalEnvironment, @@ -579,20 +573,16 @@ export default async function createApp(vite) { ogMeta : req.ogMeta, userThemes : req.userThemes }; - console.log('props: ',!!props); - return await renderSPA(req, props); - }; - const renderSPA = async (req, props)=>{ + console.log('props: ', !!props); + const htmlPath = isProd ? path.resolve('build', 'index.html') : path.resolve('index.html'); let html = fs.readFileSync(htmlPath, 'utf-8'); - if(!isProd && vite?.transformIndexHtml) { - html = await vite.transformIndexHtml(req.originalUrl, html); - } + html = html.replace( - '', - `` + '', + `` ); console.log('html', html);