From 0584fd2f763016e74bea96c480c2ef947956d5af Mon Sep 17 00:00:00 2001 From: Mohd Quamar Tyagi <347892697+Tyagiquamar@users.noreply.github.com> Date: Sun, 18 Oct 2026 22:52:48 +0530 Subject: [PATCH] fix(compute/serve): persist default override_host for Viceroy (#1435) --- pkg/commands/compute/serve.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/pkg/commands/compute/serve.go b/pkg/commands/compute/serve.go index 26b4dc49a..ae9468092 100644 --- a/pkg/commands/compute/serve.go +++ b/pkg/commands/compute/serve.go @@ -174,8 +174,6 @@ func (c *ServeCommand) Exec(in io.Reader, out io.Writer) (err error) { text.Break(out) } - c.setBackendsWithDefaultOverrideHostIfMissing(out) - spinner, err := text.NewSpinner(out) if err != nil { return err @@ -204,6 +202,10 @@ func (c *ServeCommand) Exec(in io.Reader, out io.Writer) (err error) { } } + if err := c.setBackendsWithDefaultOverrideHostIfMissing(out, manifestPath); err != nil { + return err + } + bin, err := c.GetViceroy(spinner, out, manifestPath) if err != nil { return err @@ -338,7 +340,11 @@ func (c *ServeCommand) Build(in io.Reader, out io.Writer) error { // local_server.backends that is missing that property. The value will only be // set if the URL defined uses a hostname (e.g. http://127.0.0.1/ won't) so we // can set the override_host to match the hostname. -func (c *ServeCommand) setBackendsWithDefaultOverrideHostIfMissing(out io.Writer) { +// +// Viceroy reads backend configuration from the manifest file on disk, so any +// defaults applied here are written back to manifestPath before Viceroy starts. +func (c *ServeCommand) setBackendsWithDefaultOverrideHostIfMissing(out io.Writer, manifestPath string) error { + updated := false for k, backend := range c.Globals.Manifest.File.LocalServer.Backends { if backend.OverrideHost == "" { if u, err := url.Parse(backend.URL); err == nil { @@ -349,10 +355,15 @@ func (c *ServeCommand) setBackendsWithDefaultOverrideHostIfMissing(out io.Writer } backend.OverrideHost = u.Host c.Globals.Manifest.File.LocalServer.Backends[k] = backend + updated = true } } } } + if !updated { + return nil + } + return c.Globals.Manifest.File.Write(manifestPath) } // GetViceroy returns the path to the installed binary.