From 77a2d6015756263049172fd150637eda09b1a54e Mon Sep 17 00:00:00 2001 From: mmabdalla <101379618+mmabdalla@users.noreply.github.com> Date: Mon, 29 Dec 2025 01:40:26 +0200 Subject: [PATCH] Fix: Add assets route handler to serve static files from plugin --- server.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index 68ef968..1762ebc 100644 --- a/server.js +++ b/server.js @@ -78,12 +78,22 @@ app.get('/editor', serveEditor); app.use('/api/pages', createPagesRouter()); app.get('/preview/:id', previewPage); -// Placeholder route handlers +// Serve static assets (Vite build outputs) +app.use('/assets', express.static(path.join(__dirname, 'dist', 'assets'))); + +// Route handlers async function serveEditor(req, res) { const indexPath = path.join(__dirname, 'dist', 'frontend', 'index.html'); res.sendFile(indexPath); } +async function serveAssets(req, res) { + // Extract filepath parameter (everything after /assets/) + const filepath = req.params.filepath || req.path.replace('/assets/', ''); + const assetPath = path.join(__dirname, 'dist', 'assets', filepath); + res.sendFile(assetPath); +} + async function previewPage(req, res) { try { const pageId = req.params.id;