Skip to content

Commit

Permalink
fix: redirect to https if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
ViRb3 committed May 20, 2021
1 parent 3935b0c commit 7c90dba
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions main.go
Expand Up @@ -22,6 +22,7 @@ import (
"mime"
"net/http"
"os"
"strings"
textTemplate "text/template"
"time"
)
Expand Down Expand Up @@ -145,6 +146,13 @@ func serve(host string, port uint64) {
return s == config.Current.BuilderKey, nil
})

e.Pre(middleware.HTTPSRedirectWithConfig(middleware.RedirectConfig{
Skipper: func(echo.Context) bool {
return !strings.HasPrefix(config.Current.PublicUrl, "https")
},
Code: 302,
}))

e.GET("/", renderIndex, basicAuth)
e.GET("/favicon.png", getFavIcon, basicAuth)
e.POST("/apps", uploadUnsignedApp, basicAuth)
Expand Down

0 comments on commit 7c90dba

Please sign in to comment.