From 14e10a34072c61d4a7a0afb553bda6c6ba072857 Mon Sep 17 00:00:00 2001 From: Richard LT Date: Wed, 14 Apr 2021 16:10:20 +0200 Subject: [PATCH] feat(ui): check proxy empty config (#5790) --- engine/ui/ui_router.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/engine/ui/ui_router.go b/engine/ui/ui_router.go index d6c75dc77f..d7335c5a8d 100644 --- a/engine/ui/ui_router.go +++ b/engine/ui/ui_router.go @@ -30,9 +30,15 @@ func (s *Service) initRouter(ctx context.Context) { r.Handle(s.Cfg.DeployURL+"/mon/metrics/all", nil, r.GET(service.GetMetricsHandler)) // proxypass - r.Mux.PathPrefix(s.Cfg.DeployURL + "/cdsapi").Handler(s.getReverseProxy(s.Cfg.DeployURL+"/cdsapi", s.Cfg.API.HTTP.URL)) - r.Mux.PathPrefix(s.Cfg.DeployURL + "/cdshooks").Handler(s.getReverseProxy(s.Cfg.DeployURL+"/cdshooks", s.Cfg.HooksURL)) - r.Mux.PathPrefix(s.Cfg.DeployURL + "/cdscdn").Handler(s.getReverseProxy(s.Cfg.DeployURL+"/cdscdn", s.Cfg.CDNURL)) + if s.Cfg.API.HTTP.URL != "" { + r.Mux.PathPrefix(s.Cfg.DeployURL + "/cdsapi").Handler(s.getReverseProxy(s.Cfg.DeployURL+"/cdsapi", s.Cfg.API.HTTP.URL)) + } + if s.Cfg.HooksURL != "" { + r.Mux.PathPrefix(s.Cfg.DeployURL + "/cdshooks").Handler(s.getReverseProxy(s.Cfg.DeployURL+"/cdshooks", s.Cfg.HooksURL)) + } + if s.Cfg.CDNURL != "" { + r.Mux.PathPrefix(s.Cfg.DeployURL + "/cdscdn").Handler(s.getReverseProxy(s.Cfg.DeployURL+"/cdscdn", s.Cfg.CDNURL)) + } // serve static UI files r.Mux.PathPrefix("/docs").Handler(s.uiServe(http.Dir(s.DocsDir), s.DocsDir))