From cb2353785f4f18bd389a852a2016f38a23640876 Mon Sep 17 00:00:00 2001 From: MayaTheShy Date: Fri, 20 Feb 2026 03:29:14 -0500 Subject: [PATCH] style: Add middleware to rewrite requests without /api prefix for reverse proxy compatibility --- server/server.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/server.js b/server/server.js index e1d92de..ff69532 100644 --- a/server/server.js +++ b/server/server.js @@ -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();