diff --git a/internal/outpost/proxyv2/handlers.go b/internal/outpost/proxyv2/handlers.go index c7382844d..f54170f5b 100644 --- a/internal/outpost/proxyv2/handlers.go +++ b/internal/outpost/proxyv2/handlers.go @@ -1,6 +1,8 @@ package proxyv2 import ( + "encoding/json" + "fmt" "net/http" "strings" "time" @@ -60,7 +62,23 @@ func (ps *ProxyServer) Handle(rw http.ResponseWriter, r *http.Request) { } ps.log.WithField("host", host).Warning("no app for hostname") - rw.WriteHeader(400) + + rw.Header().Set("Content-Type", "application/json") + rw.WriteHeader(http.StatusBadRequest) + j := json.NewEncoder(rw) + j.SetIndent("", "\t") + err := j.Encode(struct { + Message string + Host string + Detail string + }{ + Message: "no app for hostname", + Host: host, + Detail: fmt.Sprintf("Check the outpost settings and make sure '%s' is included.", host), + }) + if err != nil { + ps.log.WithError(err).Warning("Failed to write error body") + } return } ps.log.WithField("host", host).Trace("passing to application mux") diff --git a/web/src/pages/outposts/OutpostForm.ts b/web/src/pages/outposts/OutpostForm.ts index f5f5f8b80..b08c57bc5 100644 --- a/web/src/pages/outposts/OutpostForm.ts +++ b/web/src/pages/outposts/OutpostForm.ts @@ -73,7 +73,7 @@ export class OutpostForm extends ModelForm { value=${ifDefined(provider.pk)} ?selected=${selected} > - ${provider.assignedApplicationName} (${provider.name}) + ${provider.assignedApplicationName} (${provider.externalHost}) `; }); });