Skip to content

Commit

Permalink
fix last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
VanesStalkers committed Mar 16, 2024
1 parent 116d43d commit 964de30
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ class Server {
const host = metautil.parseHost(transport.req.headers.host);
const { protocol, ports } = this.options;
const targetPort = metautil.sample(ports);
const targetUrl = transport.req.url;
const targetUrl = transport.req.url || '/';
transport.redirect(`${protocol}://${host}:${targetPort}${targetUrl}`);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class HttpTransport extends Transport {
}

redirect(location) {
const { res } = this;
const { res, req } = this;
if (res.headersSent) return;
const code = ['GET', 'HEAD'].includes(req.method) ? 302 : 307;
res.writeHead(code, { Location: location, ...HEADERS });
Expand Down

0 comments on commit 964de30

Please sign in to comment.