From f477e1f942ecc0aaf7352e413874ace76db01a8f Mon Sep 17 00:00:00 2001 From: samanhappy Date: Fri, 18 Apr 2025 15:00:52 +0800 Subject: [PATCH] fix: add catch-all route to serve frontend index.html (#14) Co-authored-by: samanhappy@qq.com --- src/routes/index.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/routes/index.ts b/src/routes/index.ts index ade6197..45e82cc 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -1,5 +1,6 @@ import express from 'express'; import { check } from 'express-validator'; +import path from 'path'; import { getAllServers, getAllSettings, @@ -71,6 +72,10 @@ export const initRoutes = (app: express.Application): void => { ], changePassword); app.use('/api', router); + + app.get('*', (_req, res) => { + res.sendFile(path.join(process.cwd(), 'frontend', 'dist', 'index.html')); + }); }; export default router;