sync: update from private repo (8d2961c)
CI / build-and-test (push) Has been cancelled

This commit is contained in:
oss-sync
2026-06-17 01:37:03 +00:00
parent a126fe8d18
commit 35e4fd30d2
3 changed files with 105 additions and 8 deletions
+13 -6
View File
@@ -1338,14 +1338,21 @@ export function startCoreServer(opts: CoreServerOptions, port: number = 9876): v
}
});
if (tls.httpRedirect) {
if (tls.redirectHost == null && (host === '0.0.0.0' || host === '::')) {
logger.warn(
`[server] HTTP->HTTPS redirect host falls back to the wildcard bind address (${host}); browsers cannot follow it. ` +
`Set server.tls.redirect_host to the externally reachable hostname.`,
const isWildcardBind = host === '0.0.0.0' || host === '::';
// With a wildcard bind and no explicit redirect_host there is no single
// correct host to pin (the bind address itself, 0.0.0.0, is not browser-
// reachable). Derive the redirect target from the client's own Host header
// instead — a scheme upgrade to the host they already used. 'localhost' is
// only the last-resort pin for a request with no usable Host header.
const preferRequestHost = tls.redirectHost == null && isWildcardBind;
if (preferRequestHost) {
logger.info(
`[server] HTTP->HTTPS redirect derives its host from the request Host header ` +
`(wildcard bind ${host}, no server.tls.redirect_host set). Set redirect_host to pin it explicitly.`,
);
}
const pinnedHost = tls.redirectHost ?? (isLoopbackBind ? 'localhost' : host);
const redirector = createHttpRedirectServer({ httpsPort: port, pinnedHost });
const pinnedHost = tls.redirectHost ?? (isWildcardBind || isLoopbackBind ? 'localhost' : host);
const redirector = createHttpRedirectServer({ httpsPort: port, pinnedHost, preferRequestHost });
redirector.on('error', (e) => logger.warn(`[server] HTTP redirect listener error: ${(e as Error).message}`));
redirector.listen(tls.httpRedirectPort, host, () =>
logger.info(`HTTP->HTTPS redirect listening on http://${host}:${tls.httpRedirectPort}`),