style: Add middleware to rewrite requests without /api prefix for reverse proxy compatibility

This commit is contained in:
MayaTheShy
2026-02-20 03:29:14 -05:00
parent 46c0817270
commit cb2353785f

View File

@@ -12,6 +12,14 @@ const WS_PORT = 3002;
app.use(cors());
app.use(express.json({ limit: '5mb' }));
// Rewrite requests that arrive without /api prefix (from reverse proxy stripping it)
app.use((req, res, next) => {
if (!req.path.startsWith('/api') && req.path !== '/' && req.path !== '/health') {
req.url = '/api' + req.url;
}
next();
});
// Initialize database
db.initializeDatabase();