Fix: Use Express static middleware for assets, remove redundant handler
This commit is contained in:
parent
6353f89cb3
commit
036a5ec083
2 changed files with 1 additions and 12 deletions
|
|
@ -25,11 +25,6 @@ routes:
|
|||
method: GET
|
||||
handler: serveEditor
|
||||
|
||||
# Static assets route
|
||||
- path: /assets/:filepath
|
||||
method: GET
|
||||
handler: serveAssets
|
||||
|
||||
# API routes for pages
|
||||
- path: /api/pages
|
||||
method: GET
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ app.use('/api/pages', createPagesRouter());
|
|||
app.get('/preview/:id', previewPage);
|
||||
|
||||
// Serve static assets (Vite build outputs)
|
||||
// Note: BOSA forwards /bp_wb/assets/* to this plugin, so Express receives /assets/*
|
||||
app.use('/assets', express.static(path.join(__dirname, 'dist', 'assets')));
|
||||
|
||||
async function serveEditor(req, res) {
|
||||
|
|
@ -86,13 +87,6 @@ async function serveEditor(req, res) {
|
|||
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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue