tsweb: fix Port80Handler redirect to https with FQDN unset

Fixes the current http://pkgs.tailscale.com/ redirect to https:///
as that server doesn't configure the Port80Handler.FQDN field.

Change-Id: Iff56e6127a46c306ca97738d91b217bcab32a582
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2022-06-05 11:23:55 -07:00
committed by Brad Fitzpatrick
parent c6ac82e3a6
commit 0df3b76c25
2 changed files with 43 additions and 1 deletions

View File

@@ -162,7 +162,7 @@ func (h Port80Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
host := h.FQDN
if host == "" {
host = r.URL.Hostname()
host = r.Host
}
target := "https://" + host + path
http.Redirect(w, r, target, http.StatusFound)