feat: improve getOriginFromHost() for local machine name

This commit is contained in:
Yang Luo 2023-07-05 09:51:08 +08:00
parent 28297e06f7
commit 855259c6e7

View File

@ -65,10 +65,13 @@ func getOriginFromHost(host string) (string, string) {
return origin, origin
}
// "door.casdoor.com"
protocol := "https://"
if strings.HasPrefix(host, "localhost") {
if !strings.Contains(host, ".") {
// "localhost:8000" or "computer-name:80"
protocol = "http://"
} else if isIpAddress(host) {
// "192.168.0.10"
protocol = "http://"
}