|
|
@@ -22,22 +22,21 @@ export function createServer(apiKey: string, jobQueue: JobQueue, db?: ShopDataba
|
|
|
next();
|
|
|
});
|
|
|
|
|
|
- // Serve static files from web UI (must come before catch-all)
|
|
|
+ // Root path - return empty JSON
|
|
|
+ app.get('/', (req, res) => {
|
|
|
+ res.json({});
|
|
|
+ });
|
|
|
+
|
|
|
+ // Serve static files from web UI at /ui
|
|
|
const webUIPath = path.join(__dirname, '../../dist/web');
|
|
|
- app.use(express.static(webUIPath));
|
|
|
+ app.use('/ui', express.static(webUIPath));
|
|
|
|
|
|
// API routes (authentication handled per endpoint based on documentation)
|
|
|
const router = createRouter(jobQueue, apiKey, db, config);
|
|
|
app.use('/', router);
|
|
|
|
|
|
- // Catch all handler for SPA - serve index.html for all non-API routes
|
|
|
- app.get('*', (req, res) => {
|
|
|
- // Don't serve index.html for API routes that don't exist
|
|
|
- if (req.path.startsWith('/api/')) {
|
|
|
- return res.status(404).json({ error: 'Not found' });
|
|
|
- }
|
|
|
-
|
|
|
- // Serve index.html for all other routes (SPA routing)
|
|
|
+ // Catch all handler for SPA - serve index.html for /ui/* routes
|
|
|
+ app.get('/ui/*', (req, res) => {
|
|
|
const indexPath = path.join(webUIPath, 'index.html');
|
|
|
res.sendFile(indexPath, (err) => {
|
|
|
if (err) {
|