From 1e9e3cacccd2f654f37f11ac6d20c46a2c41a148 Mon Sep 17 00:00:00 2001 From: Nour Alharithi Date: Thu, 14 Dec 2023 18:19:31 -0800 Subject: [PATCH] strip off ui from path in server lite --- src/serverLite.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/serverLite.ts b/src/serverLite.ts index 8a03b22..4a0a062 100644 --- a/src/serverLite.ts +++ b/src/serverLite.ts @@ -99,6 +99,17 @@ app.use((req, _res, next) => { next(); }); +// strip off /ui, if the request comes from the UI +app.use((req, _res, next) => { + if (req.url.startsWith('/ui')) { + req.url = req.url.replace('/ui', ''); + if (req.url === '') { + req.url = '/'; + } + } + next(); +}); + app.use(errorHandler); const server = http.createServer(app);