Skip to content

Commit 53fd499

Browse files
authored
Fix 404 in Admin Console (#4980)
1 parent 99139b5 commit 53fd499

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed
File renamed without changes.

kurl_proxy/assets/welcome.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
.replace(/\/$/, "");
2020
var httpsLink = "http:" + rawLink;
2121
var opensslLink = rawLink.substring(2).replace("/", "");
22-
var insecureLink = httpsLink + "/insecure";
22+
var insecureLink = httpsLink + "/tls-warning";
2323
</script>
2424
<body>
2525
<div class="u-minHeight--full u-width--full flex flex-column flex1">

kurl_proxy/cmd/main.go

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,34 @@ func getHttpServer(fingerprint string, acceptAnonymousUploads bool, assetsDir st
275275
}
276276

277277
appIcon := template.URL(app.Spec.Icon)
278-
htmlPage := "welcome.html"
279-
if c.Request.URL.Path == "/insecure" {
280-
htmlPage = "insecure.html"
278+
c.HTML(http.StatusOK, "welcome.html", gin.H{
279+
"fingerprintSHA1": fingerprint,
280+
"AppIcon": appIcon,
281+
"AppTitle": app.Spec.Title,
282+
"IsEmbeddedCluster": isEmbeddedCluster(),
283+
})
284+
})
285+
r.GET("/tls-warning", func(c *gin.Context) {
286+
if !acceptAnonymousUploads {
287+
log.Println("TLS certs already uploaded, redirecting to https")
288+
target := url.URL{
289+
Scheme: "https",
290+
Host: c.Request.Host,
291+
Path: c.Request.URL.Path,
292+
RawQuery: c.Request.URL.RawQuery,
293+
}
294+
// Returns StatusFound (302) to avoid browser caching
295+
c.Redirect(http.StatusFound, target.String())
296+
return
297+
}
298+
299+
app, err := kotsadmApplication()
300+
301+
if err != nil {
302+
log.Printf("No kotsadm application metadata: %v", err) // continue
281303
}
282-
c.HTML(http.StatusOK, htmlPage, gin.H{
304+
appIcon := template.URL(app.Spec.Icon)
305+
c.HTML(http.StatusOK, "tls-warning.html", gin.H{
283306
"fingerprintSHA1": fingerprint,
284307
"AppIcon": appIcon,
285308
"AppTitle": app.Spec.Title,

0 commit comments

Comments
 (0)