From 90e8714e7149daf47aa09321d64a04ffd9266ee2 Mon Sep 17 00:00:00 2001 From: Asher Date: Mon, 12 Aug 2019 11:46:58 -0500 Subject: [PATCH] Preserve query variables when redirecting --- src/server.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/server.ts b/src/server.ts index 402e2b906..f853c21a3 100644 --- a/src/server.ts +++ b/src/server.ts @@ -189,7 +189,8 @@ export abstract class Server { } protected withBase(request: http.IncomingMessage, path: string): string { - return `${this.protocol}://${request.headers.host}${this.options.basePath}${path}`; + const split = request.url ? request.url.split("?", 2) : []; + return `${this.protocol}://${request.headers.host}${this.options.basePath}${path}${split.length === 2 ? `?${split[1]}` : ""}`; } private onRequest = async (request: http.IncomingMessage, response: http.ServerResponse): Promise => {