Skip to content

Commit

Permalink
ssl.redirectHttpFromPort: use host from request instead of config (e…
Browse files Browse the repository at this point in the history
  • Loading branch information
pgayvallet authored Jul 12, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 180fc29 commit 49cfa96
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -96,3 +96,14 @@ test('forwards http requests to https', async () => {
expect(res.header.location).toEqual(`https://${config.host}:${config.port}/`);
});
});

test('keeps the request host when redirecting', async () => {
await server.start(config);

await supertest(`http://localhost:${config.ssl.redirectHttpFromPort}`)
.get('/')
.expect(302)
.then((res) => {
expect(res.header.location).toEqual(`https://localhost:${config.port}/`);
});
});
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ export class HttpsRedirectServer {
return responseToolkit
.redirect(
formatUrl({
hostname: config.host,
hostname: request.url.hostname,
pathname: request.url.pathname,
port: config.port,
protocol: 'https',

0 comments on commit 49cfa96

Please sign in to comment.