Use middleware fallback for SPA routing

This commit is contained in:
Jurgis Sakalauskas
2025-11-14 10:37:32 +02:00
parent c084e3261c
commit eae6e08053
+2 -5
View File
@@ -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}".`