Skip to content

Commit

Permalink
Implements CONSOLE_DEV_MODE env var (#2517)
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
  • Loading branch information
bexsoft committed Dec 16, 2022
1 parent f917f7d commit f61d0a6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions restapi/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,7 @@ func getMaxConcurrentDownloadsLimit() int64 {

return cu
}

func getConsoleDevMode() bool {
return strings.ToLower(env.Get(ConsoleDevMode, "off")) == "on"
}
1 change: 1 addition & 0 deletions restapi/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "/"
)
10 changes: 6 additions & 4 deletions restapi/ws_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f61d0a6

Please sign in to comment.