internal: listen on localhost for dev_appserver; avoid macOS Firewall (#45)
Without this, the macOS firewall asks if _ah_exe should accept
incoming network connections, since by default it listens on all
interfaces. For development purposes, it is sufficient to only listen
on localhost.
diff --git a/internal/main_vm.go b/internal/main_vm.go
index 57331ad..822e784 100644
--- a/internal/main_vm.go
+++ b/internal/main_vm.go
@@ -22,7 +22,11 @@
port = s
}
- if err := http.ListenAndServe(":"+port, http.HandlerFunc(handleHTTP)); err != nil {
+ host := ""
+ if IsDevAppServer() {
+ host = "127.0.0.1"
+ }
+ if err := http.ListenAndServe(host+":"+port, http.HandlerFunc(handleHTTP)); err != nil {
log.Fatalf("http.ListenAndServe: %v", err)
}
}