feat: introduce routing system

This commit is contained in:
2025-10-23 11:38:03 +02:00
parent c6949c36c1
commit 531ddbee85
4 changed files with 69 additions and 16 deletions

View File

@@ -19,12 +19,7 @@ const PORT = process.env.PORT || 3000;
// Serve static files from public directory
app.use(express.static(path.join(__dirname, 'public')));
// Serve the main HTML page
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'index.html'));
});
// Health check endpoint
// Health check endpoint (before catch-all route)
app.get('/health', (req, res) => {
res.json({
status: 'healthy',
@@ -34,6 +29,13 @@ app.get('/health', (req, res) => {
});
});
// SPA catch-all route - serves index.html for all routes
// This allows client-side routing to work properly
// Using regex pattern for Express 5 compatibility
app.get(/^\/(?!health$).*/, (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'index.html'));
});
// Start the server
app.listen(PORT, '0.0.0.0', () => {
console.log(`SPORE UI Frontend Server is running on http://0.0.0.0:${PORT}`);