From 4101ed2f30bca7ed07bb16f6a259ce732670f737 Mon Sep 17 00:00:00 2001
From: Sakala Venkata Krishna Rohit <rohit.sakala@suse.com>
Date: Mon, 14 Apr 2025 12:37:15 -0700
Subject: [PATCH] Add log message to log the error from http client (#596)

---
 pkg/ui/handler.go | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/pkg/ui/handler.go b/pkg/ui/handler.go
index 69c562c8..38bf2d55 100644
--- a/pkg/ui/handler.go
+++ b/pkg/ui/handler.go
@@ -1,7 +1,6 @@
 package ui
 
 import (
-	"crypto/tls"
 	"io"
 	"io/ioutil"
 	"net/http"
@@ -13,17 +12,6 @@ import (
 	"github.com/sirupsen/logrus"
 )
 
-var (
-	insecureClient = &http.Client{
-		Transport: &http.Transport{
-			Proxy: http.ProxyFromEnvironment,
-			TLSClientConfig: &tls.Config{
-				InsecureSkipVerify: true,
-			},
-		},
-	}
-)
-
 const (
 	defaultPath = "./ui"
 )
@@ -158,7 +146,10 @@ func (u *Handler) IndexFileOnNotFound() http.Handler {
 func (u *Handler) IndexFile() http.Handler {
 	return u.indexMiddleware(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
 		if path, isURL := u.path(); isURL {
-			_ = serveIndex(rw, path)
+			err := serveIndex(rw, path)
+			if err != nil {
+				logrus.Errorf("failed to download %s: %v", path, err)
+			}
 		} else {
 			http.ServeFile(rw, req, filepath.Join(path, "index.html"))
 		}
@@ -166,7 +157,12 @@ func (u *Handler) IndexFile() http.Handler {
 }
 
 func serveIndex(resp io.Writer, url string) error {
-	r, err := insecureClient.Get(url)
+	client := &http.Client{
+		Transport: &http.Transport{
+			Proxy: http.ProxyFromEnvironment,
+		},
+	}
+	r, err := client.Get(url)
 	if err != nil {
 		return err
 	}