Implements CONSOLE_DEV_MODE env var (#2517)

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
This commit is contained in:
Alex
2022-12-16 13:32:52 -06:00
committed by GitHub
parent f917f7d167
commit f61d0a68d5
3 changed files with 11 additions and 4 deletions

View File

@@ -272,3 +272,7 @@ func getMaxConcurrentDownloadsLimit() int64 {
return cu
}
func getConsoleDevMode() bool {
return strings.ToLower(env.Get(ConsoleDevMode, "off")) == "on"
}

View File

@@ -53,6 +53,7 @@ const (
ConsoleLogQueryAuthToken = "CONSOLE_LOG_QUERY_AUTH_TOKEN"
ConsoleMaxConcurrentUploads = "CONSOLE_MAX_CONCURRENT_UPLOADS"
ConsoleMaxConcurrentDownloads = "CONSOLE_MAX_CONCURRENT_DOWNLOADS"
ConsoleDevMode = "CONSOLE_DEV_MODE"
LogSearchQueryAuthToken = "LOGSEARCH_QUERY_AUTH_TOKEN"
SlashSeparator = "/"
)

View File

@@ -148,10 +148,12 @@ func serveWS(w http.ResponseWriter, req *http.Request) {
return
}
// Un-comment for development so websockets work on port 5005
/*upgrader.CheckOrigin = func(r *http.Request) bool {
return true
}*/
// Development mode validation
if getConsoleDevMode() {
upgrader.CheckOrigin = func(r *http.Request) bool {
return true
}
}
// upgrades the HTTP server connection to the WebSocket protocol.
conn, err := upgrader.Upgrade(w, req, nil)