Skip to content

Commit 90e8714

Browse files
committed
Preserve query variables when redirecting
1 parent 5539519 commit 90e8714

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ export abstract class Server {
189189
}
190190

191191
protected withBase(request: http.IncomingMessage, path: string): string {
192-
return `${this.protocol}://${request.headers.host}${this.options.basePath}${path}`;
192+
const split = request.url ? request.url.split("?", 2) : [];
193+
return `${this.protocol}://${request.headers.host}${this.options.basePath}${path}${split.length === 2 ? `?${split[1]}` : ""}`;
193194
}
194195

195196
private onRequest = async (request: http.IncomingMessage, response: http.ServerResponse): Promise<void> => {

0 commit comments

Comments
 (0)