Skip to content

Commit

Permalink
Fix 404 in Admin Console (#4980)
Browse files Browse the repository at this point in the history
  • Loading branch information
miaawong authored Nov 1, 2024
1 parent 99139b5 commit 53fd499
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion kurl_proxy/assets/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
.replace(/\/$/, "");
var httpsLink = "http:" + rawLink;
var opensslLink = rawLink.substring(2).replace("/", "");
var insecureLink = httpsLink + "/insecure";
var insecureLink = httpsLink + "/tls-warning";
</script>
<body>
<div class="u-minHeight--full u-width--full flex flex-column flex1">
Expand Down
31 changes: 27 additions & 4 deletions kurl_proxy/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,34 @@ func getHttpServer(fingerprint string, acceptAnonymousUploads bool, assetsDir st
}

appIcon := template.URL(app.Spec.Icon)
htmlPage := "welcome.html"
if c.Request.URL.Path == "/insecure" {
htmlPage = "insecure.html"
c.HTML(http.StatusOK, "welcome.html", gin.H{
"fingerprintSHA1": fingerprint,
"AppIcon": appIcon,
"AppTitle": app.Spec.Title,
"IsEmbeddedCluster": isEmbeddedCluster(),
})
})
r.GET("/tls-warning", func(c *gin.Context) {
if !acceptAnonymousUploads {
log.Println("TLS certs already uploaded, redirecting to https")
target := url.URL{
Scheme: "https",
Host: c.Request.Host,
Path: c.Request.URL.Path,
RawQuery: c.Request.URL.RawQuery,
}
// Returns StatusFound (302) to avoid browser caching
c.Redirect(http.StatusFound, target.String())
return
}

app, err := kotsadmApplication()

if err != nil {
log.Printf("No kotsadm application metadata: %v", err) // continue
}
c.HTML(http.StatusOK, htmlPage, gin.H{
appIcon := template.URL(app.Spec.Icon)
c.HTML(http.StatusOK, "tls-warning.html", gin.H{
"fingerprintSHA1": fingerprint,
"AppIcon": appIcon,
"AppTitle": app.Spec.Title,
Expand Down

0 comments on commit 53fd499

Please sign in to comment.