diff --git a/certificates.go b/certificates.go index a27816649..d95d1d8f5 100644 --- a/certificates.go +++ b/certificates.go @@ -29,7 +29,7 @@ import ( ) var ( - host = "127.0.0.1" + host = "localhost" validFrom = "" validFor = 365 * 24 * time.Hour * 2 // 2 years rsaBits = 2048 diff --git a/info.go b/info.go index af41596dd..8a66ca474 100644 --- a/info.go +++ b/info.go @@ -15,9 +15,9 @@ func infoHandler(c *gin.Context) { c.JSON(200, gin.H{ "version": version, "http": "http://" + host + port, - "https": "https://" + host + portSSL, + "https": "https://localhost" + portSSL, "ws": "ws://" + host + port, - "wss": "wss://" + host + portSSL, + "wss": "wss://localhost" + portSSL, }) } diff --git a/main.go b/main.go index 273e5d6fd..6f36328d8 100755 --- a/main.go +++ b/main.go @@ -11,6 +11,7 @@ import ( "path/filepath" "runtime/debug" "strconv" + "strings" "text/template" "time" @@ -188,14 +189,20 @@ func main() { socketHandler := wsHandler().ServeHTTP - extraOriginStr := "https://create.arduino.cc, http://create.arduino.cc, https://create-dev.arduino.cc, http://create-dev.arduino.cc, https://create-intel.arduino.cc, http://create-intel.arduino.cc" + extraOrigins := []string{ + "https://create.arduino.cc", + "http://create.arduino.cc", "https://create-dev.arduino.cc", "http://create-dev.arduino.cc", "https://create-intel.arduino.cc", "http://create-intel.arduino.cc", + } for i := 8990; i < 9001; i++ { - extraOriginStr = extraOriginStr + ", http://localhost:" + strconv.Itoa(i) + ", https://localhost:" + strconv.Itoa(i) + port := strconv.Itoa(i) + extraOrigins = append(extraOrigins, "http://localhost:"+port) + extraOrigins = append(extraOrigins, "https://localhost:"+port) + extraOrigins = append(extraOrigins, "http://127.0.0.1:"+port) } r.Use(cors.Middleware(cors.Config{ - Origins: *origins + ", " + extraOriginStr, + Origins: *origins + ", " + strings.Join(extraOrigins, ", "), Methods: "GET, PUT, POST, DELETE", RequestHeaders: "Origin, Authorization, Content-Type", ExposedHeaders: "",