Skip to content

Commit

Permalink
satellite/console: update ui server with new configs
Browse files Browse the repository at this point in the history
This change updates the UI server to handle new UI config flags,
PrefixVuetifyUI and VuetifyHost. It also updates the ""/v2" to "/"
redirect to append query parameters.

Change-Id: I8dff23737762d1d3b81c77066274f6ba5a317ec9
  • Loading branch information
wilfred-asomanii authored and Storj Robot committed Jan 17, 2024
1 parent 50576c4 commit 615cd8e
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions satellite/console/consoleweb/server.go
Expand Up @@ -405,21 +405,23 @@ func NewServer(logger *zap.Logger, config Config, service *console.Service, oidc
fs := http.FileServer(http.Dir(server.config.StaticDir))
router.PathPrefix("/static/").Handler(server.withCORS(server.brotliMiddleware(http.StripPrefix("/static", fs))))

if server.config.PrefixVuetifyUI {
if server.config.UseVuetifyProject {
if server.config.UseVuetifyProject {
if server.config.PrefixVuetifyUI {
if server.config.VuetifyHost != "" {
router.Host(server.config.VuetifyHost).Handler(server.withCORS(http.HandlerFunc(server.vuetifyAppHandler)))
} else {
// if not using a custom subdomain for vuetify, use a path prefix on the same domain as the production app
router.PathPrefix("/v2").Handler(server.withCORS(http.HandlerFunc(server.vuetifyAppHandler)))
}
router.PathPrefix("/").Handler(server.withCORS(http.HandlerFunc(server.appHandler)))
} else {
router.PathPrefix("/v2").Handler(server.withCORS(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, strings.TrimPrefix(r.URL.Path, "/v2"), http.StatusMovedPermanently)
})))
router.PathPrefix("/").Handler(server.withCORS(http.HandlerFunc(server.vuetifyAppHandler)))
}
router.PathPrefix("/").Handler(server.withCORS(http.HandlerFunc(server.appHandler)))
} else {
router.PathPrefix("/v2").Handler(server.withCORS(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, strings.TrimPrefix(r.URL.Path, "/v2"), http.StatusMovedPermanently)
})))
router.PathPrefix("/").Handler(server.withCORS(http.HandlerFunc(server.vuetifyAppHandler)))
router.PathPrefix("/").Handler(server.withCORS(http.HandlerFunc(server.appHandler)))
}
}

Expand Down Expand Up @@ -524,10 +526,26 @@ func NewFrontendServer(logger *zap.Logger, config Config, listener net.Listener,
router.HandleFunc("/robots.txt", server.seoHandler)
router.PathPrefix("/static/").Handler(server.brotliMiddleware(http.StripPrefix("/static", fs)))
router.HandleFunc("/config", server.frontendConfigHandler)

if server.config.UseVuetifyProject {
router.PathPrefix("/v2").Handler(http.HandlerFunc(server.vuetifyAppHandler))
if server.config.PrefixVuetifyUI {
if server.config.VuetifyHost != "" {
router.Host(server.config.VuetifyHost).Handler(server.withCORS(http.HandlerFunc(server.vuetifyAppHandler)))
} else {
// if not using a custom subdomain for vuetify, use a path prefix on the same domain as the production app
router.PathPrefix("/v2").Handler(server.withCORS(http.HandlerFunc(server.vuetifyAppHandler)))
}
router.PathPrefix("/").Handler(server.withCORS(http.HandlerFunc(server.appHandler)))
} else {
router.PathPrefix("/v2").Handler(server.withCORS(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, strings.TrimPrefix(r.URL.Path, "/v2"), http.StatusMovedPermanently)
})))
router.PathPrefix("/").Handler(server.withCORS(http.HandlerFunc(server.vuetifyAppHandler)))
}
} else {
router.PathPrefix("/").Handler(server.withCORS(http.HandlerFunc(server.appHandler)))
}
router.PathPrefix("/").Handler(http.HandlerFunc(server.appHandler))

server.server = http.Server{
Handler: server.withRequest(router),
MaxHeaderBytes: ContentLengthLimit.Int(),
Expand Down

0 comments on commit 615cd8e

Please sign in to comment.