diff options
author | sth <sth.dev@tejp.de> | 2020-12-02 12:52:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-02 12:52:26 +0100 |
commit | 0ad378b09cea90a2a70d7ff06af668abe22475a1 (patch) | |
tree | b8513e229047459cb2337e6dff69aa26640039db /commands/server.go | |
parent | aebfe156fb2f27057e61b2e50c7576e6b06dab58 (diff) |
Use --baseURL path for live-reload URL
Fixes #6595
Diffstat (limited to 'commands/server.go')
-rw-r--r-- | commands/server.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/commands/server.go b/commands/server.go index b6a8d282c..ef504f20f 100644 --- a/commands/server.go +++ b/commands/server.go @@ -357,7 +357,9 @@ func (f *fileServer) createEndpoint(i int) (*http.ServeMux, string, string, erro if !f.c.paused { port = f.c.Cfg.GetInt("liveReloadPort") } - fmt.Fprint(w, injectLiveReloadScript(r, port)) + lr := *u + lr.Host = fmt.Sprintf("%s:%d", lr.Hostname(), port) + fmt.Fprint(w, injectLiveReloadScript(r, lr)) return } @@ -501,8 +503,13 @@ func (c *commandeer) serve(s *serverCmd) error { mu, serverURL, endpoint, err := srv.createEndpoint(i) if doLiveReload { - mu.HandleFunc("/livereload.js", livereload.ServeJS) - mu.HandleFunc("/livereload", livereload.Handler) + u, err := url.Parse(helpers.SanitizeURL(baseURLs[i])) + if err != nil { + return err + } + + mu.HandleFunc(u.Path+"/livereload.js", livereload.ServeJS) + mu.HandleFunc(u.Path+"/livereload", livereload.Handler) } jww.FEEDBACK.Printf("Web Server is available at %s (bind address %s)\n", serverURL, s.serverInterface) go func() { |