Fix: Add assets route handler to serve static files from plugin
This commit is contained in:
parent
fc8534168f
commit
77a2d60157
1 changed files with 11 additions and 1 deletions
12
server.js
12
server.js
|
|
@ -78,12 +78,22 @@ app.get('/editor', serveEditor);
|
||||||
app.use('/api/pages', createPagesRouter());
|
app.use('/api/pages', createPagesRouter());
|
||||||
app.get('/preview/:id', previewPage);
|
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) {
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
async function previewPage(req, res) {
|
||||||
try {
|
try {
|
||||||
const pageId = req.params.id;
|
const pageId = req.params.id;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue