Skip to content

Commit 65d3785

Browse files
committed
https is possible only with localhost (not 127.0.0.1)
1 parent 319cac4 commit 65d3785

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

certificates.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
)
3030

3131
var (
32-
host = "127.0.0.1"
32+
host = "localhost"
3333
validFrom = ""
3434
validFor = 365 * 24 * time.Hour * 2 // 2 years
3535
rsaBits = 2048

info.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ func infoHandler(c *gin.Context) {
1515
c.JSON(200, gin.H{
1616
"version": version,
1717
"http": "http://" + host + port,
18-
"https": "https://" + host + portSSL,
18+
"https": "https://localhost" + portSSL,
1919
"ws": "ws://" + host + port,
20-
"wss": "wss://" + host + portSSL,
20+
"wss": "wss://localhost" + portSSL,
2121
})
2222
}
2323

main.go

+10-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"path/filepath"
1212
"runtime/debug"
1313
"strconv"
14+
"strings"
1415
"text/template"
1516
"time"
1617

@@ -188,14 +189,20 @@ func main() {
188189

189190
socketHandler := wsHandler().ServeHTTP
190191

191-
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"
192+
extraOrigins := []string{
193+
"https://create.arduino.cc",
194+
"http://create.arduino.cc", "https://create-dev.arduino.cc", "http://create-dev.arduino.cc", "https://create-intel.arduino.cc", "http://create-intel.arduino.cc",
195+
}
192196

193197
for i := 8990; i < 9001; i++ {
194-
extraOriginStr = extraOriginStr + ", http://localhost:" + strconv.Itoa(i) + ", https://localhost:" + strconv.Itoa(i)
198+
port := strconv.Itoa(i)
199+
extraOrigins = append(extraOrigins, "http://localhost:"+port)
200+
extraOrigins = append(extraOrigins, "https://localhost:"+port)
201+
extraOrigins = append(extraOrigins, "http://127.0.0.1:"+port)
195202
}
196203

197204
r.Use(cors.Middleware(cors.Config{
198-
Origins: *origins + ", " + extraOriginStr,
205+
Origins: *origins + ", " + strings.Join(extraOrigins, ", "),
199206
Methods: "GET, PUT, POST, DELETE",
200207
RequestHeaders: "Origin, Authorization, Content-Type",
201208
ExposedHeaders: "",

0 commit comments

Comments
 (0)