Fix fleetctl setup requiring https for localhost (#1270)

This fixes a reversion with fleetctl setup that requires https even for localhost connections. This was previously fixed in #489.
This commit is contained in:
Scott Lampert 2021-06-30 16:31:37 -06:00 committed by GitHub
parent 6649d08a05
commit fee860bc7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,6 +4,7 @@ import (
"context"
"errors"
"net/url"
"strings"
"github.com/fleetdm/fleet/v4/server/fleet"
)
@ -31,8 +32,10 @@ func validateServerURL(urlString string) error {
if err != nil {
return err
}
if serverURL.Scheme != "https" {
if serverURL.Scheme != "https" && !strings.Contains(serverURL.Host, "localhost") {
return errors.New("url scheme must be https")
}
return nil
}