From eae6e0805376e245e6cb077fb495dc11567dac66 Mon Sep 17 00:00:00 2001 From: Jurgis Sakalauskas Date: Fri, 14 Nov 2025 10:37:32 +0200 Subject: [PATCH] Use middleware fallback for SPA routing --- server/src/app.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/server/src/app.ts b/server/src/app.ts index 87341a5..da4a63d 100644 --- a/server/src/app.ts +++ b/server/src/app.ts @@ -16,7 +16,7 @@ if (env.client.serve) { if (fs.existsSync(clientDistPath) && fs.existsSync(indexHtmlPath)) { app.use(express.static(clientDistPath)); - const spaHandler = (req: express.Request, res: express.Response, next: express.NextFunction) => { + app.use((req, res, next) => { if (req.method !== 'GET' && req.method !== 'HEAD') { return next(); } @@ -34,10 +34,7 @@ if (env.client.serve) { } return res.sendFile(indexHtmlPath); - }; - - app.get('/*', spaHandler); - app.head('/*', spaHandler); + }); } else { console.warn( `Static client assets not served because the build output was not found at "${clientDistPath}".`