diff --git a/manifest.yaml b/manifest.yaml index d704b61..f7d0750 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -25,6 +25,11 @@ routes: method: GET handler: serveEditor + # Static assets route (for Vite build outputs) + - path: /assets/:filepath + method: GET + handler: serveAssets + # API routes for pages - path: /api/pages method: GET diff --git a/server.js b/server.js index e728166..90d49b3 100644 --- a/server.js +++ b/server.js @@ -83,6 +83,18 @@ app.get('/preview/:id', previewPage); // The base path in Vite config ensures assets are referenced as /bp_wb/assets/* app.use('/assets', express.static(path.join(__dirname, 'dist', 'assets'))); +// Handler function for manifest route (BOSA calls this) +async function serveAssets(req, res) { + const filepath = req.params.filepath || req.path.replace('/assets/', ''); + const assetPath = path.join(__dirname, 'dist', 'assets', filepath); + res.sendFile(assetPath, (err) => { + if (err) { + bosa.log?.error(`Failed to serve asset: ${filepath} | Error: ${err.message}`); + res.status(404).json({ error: 'Asset not found' }); + } + }); +} + async function serveEditor(req, res) { const indexPath = path.join(__dirname, 'dist', 'frontend', 'index.html'); res.sendFile(indexPath);