diff --git a/src/http/server.ts b/src/http/server.ts index 08082f8..5ee38aa 100644 --- a/src/http/server.ts +++ b/src/http/server.ts @@ -4,7 +4,7 @@ import { IncomingMessage, RequestListener, ServerResponse } from 'http' import { promises as fsPromisified } from 'fs' const basePath = __dirname + '/../../webif/build' -const webRoutes = ['/', '/configuration'] +const webRoutes = ['/', '/configuration', '/group'] const mimeTypes = new Map([ ['.html', 'text/html'], @@ -39,7 +39,7 @@ const resolveFilePath = (reqUrl: string | undefined): string => { // "Convert" routes to file path let filePath - if (!reqUrl || webRoutes.includes(reqUrl)) { + if (!reqUrl || isWebRoute(reqUrl)) { filePath = '/index.html' } else { filePath = reqUrl @@ -48,6 +48,16 @@ const resolveFilePath = (reqUrl: string | undefined): string => { return basePath + filePath } +const isWebRoute = (reqUrl: string): boolean => { + for (const route of webRoutes) { + if (reqUrl.startsWith(route)) { + return true + } + } + + return false +} + const serveStaticFile = async ( filePath: string, contentType: string | undefined,