From c959617bf6e1e14b2589da310dc06ba4e816b718 Mon Sep 17 00:00:00 2001 From: Ross Golder Date: Fri, 15 Oct 2021 08:29:11 +0700 Subject: [PATCH] Fix for inconsistency between address we bind to and address we say we bind to (refs #113). --- internal/render/site.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/render/site.go b/internal/render/site.go index 0fb2407..9951804 100644 --- a/internal/render/site.go +++ b/internal/render/site.go @@ -13,6 +13,8 @@ import ( "github.com/yosssi/ace" ) +const BindAddress = "0.0.0.0" + var ServePort int var upgrader = websocket.Upgrader{ @@ -94,13 +96,13 @@ func Build(output string, live bool) error { go func() { http.Handle("/", http.FileServer(http.Dir(filepath.Join(".", "output")))) - err := http.ListenAndServe(fmt.Sprintf("0.0.0.0:%d", ServePort), nil) + err := http.ListenAndServe(fmt.Sprintf("%s:%d", BindAddress, ServePort), nil) if err != nil { panic(err) } }() - fmt.Printf("Serving content of output/ at http://127.0.0.1:%d (ctrl-c to quit)\n", ServePort) + fmt.Printf("Serving content of output/ at http://%s:%d (ctrl-c to quit)\n", BindAddress, ServePort) } // PDF wg.Add(1)