Optimize filesystem routes

This commit is contained in:
Alex Gleason 2024-05-25 11:18:17 -05:00
parent 40f72f750e
commit 1ee0ca8d5c
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 22 additions and 4 deletions

View File

@ -247,11 +247,29 @@ app.get('/api/v1/lists', emptyArrayController);
app.use('/api/*', notImplementedController); app.use('/api/*', notImplementedController);
app.get('*', serveStatic({ root: './public/' })); const publicFiles = serveStatic({ root: './public/' });
app.get('*', serveStatic({ root: './static/' })); const staticFiles = serveStatic({ root: './static/' });
app.get('*', serveStatic({ path: './public/index.html' })); const frontendController = serveStatic({ path: './public/index.html' });
app.get('/', indexController); // Known frontend routes
app.get('/@:acct', frontendController);
app.get('/@:acct/*', frontendController);
app.get('/users/*', frontendController);
app.get('/statuses/*', frontendController);
app.get('/notice/*', frontendController);
// Known static file routes
app.get('/favicon.ico', publicFiles, staticFiles);
app.get('/images/*', publicFiles, staticFiles);
app.get('/instance/*', publicFiles);
app.get('/packs/*', publicFiles);
app.get('/sw.js', publicFiles);
// Site index
app.get('/', frontendController, indexController);
// Fallback
app.get('*', publicFiles, staticFiles, frontendController);
export default app; export default app;