From 00fe98de2f09559f829bb1d1ff85bebf5df6b277 Mon Sep 17 00:00:00 2001 From: Akhil Lawrence Date: Mon, 13 Jan 2020 13:32:11 +0530 Subject: [PATCH] handle basePath --- src/node/server.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/node/server.ts b/src/node/server.ts index ff4c88e1801b..51a66dc81d37 100644 --- a/src/node/server.ts +++ b/src/node/server.ts @@ -267,7 +267,12 @@ export abstract class Server { return { redirect: request.url }; } - const fullPath = decodeURIComponent(parsedUrl.pathname || "/"); + // handle basePath + let fullPath = decodeURIComponent(parsedUrl.pathname || "/"); + if (this.options.basePath) { + fullPath = fullPath.replace(this.options.basePath, "") || "/"; + } + const match = fullPath.match(/^(\/?[^/]*)(.*)$/); let [/* ignore */, base, requestPath] = match ? match.map((p) => p.replace(/\/+$/, ""))