Fix: Add serveAssets handler function for manifest route
This commit is contained in:
parent
ea271b5975
commit
95801c09f5
2 changed files with 17 additions and 0 deletions
|
|
@ -25,6 +25,11 @@ routes:
|
||||||
method: GET
|
method: GET
|
||||||
handler: serveEditor
|
handler: serveEditor
|
||||||
|
|
||||||
|
# Static assets route (for Vite build outputs)
|
||||||
|
- path: /assets/:filepath
|
||||||
|
method: GET
|
||||||
|
handler: serveAssets
|
||||||
|
|
||||||
# API routes for pages
|
# API routes for pages
|
||||||
- path: /api/pages
|
- path: /api/pages
|
||||||
method: GET
|
method: GET
|
||||||
|
|
|
||||||
12
server.js
12
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/*
|
// The base path in Vite config ensures assets are referenced as /bp_wb/assets/*
|
||||||
app.use('/assets', express.static(path.join(__dirname, 'dist', '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) {
|
async function serveEditor(req, res) {
|
||||||
const indexPath = path.join(__dirname, 'dist', 'frontend', 'index.html');
|
const indexPath = path.join(__dirname, 'dist', 'frontend', 'index.html');
|
||||||
res.sendFile(indexPath);
|
res.sendFile(indexPath);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue