Skip to content

Commit

Permalink
fix: allow all origins in devMode
Browse files Browse the repository at this point in the history
  • Loading branch information
wesbillman committed Nov 20, 2024
1 parent 2afcdc6 commit 309be0e
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions frontend/cli/cmd_serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,19 @@ func (s *serveCommonConfig) run(
controllerAddresses = append(controllerAddresses, controllerBind)
}

for _, addr := range controllerAddresses {
// Add controller address to allow origins for console requests.
// The console is run on `localhost` so we replace 127.0.0.1 with localhost.
if addr.Hostname() == "127.0.0.1" {
addr.Host = "localhost" + ":" + addr.Port()
}
s.CommonConfig.AllowOrigins = append(s.CommonConfig.AllowOrigins, addr)
}

if devMode && len(s.CommonConfig.AllowHeaders) == 0 {
// Default to allowing all headers for console requests in local dev mode.
if devMode {
// Default to allowing all origins and headers for console requests in local dev mode.
s.CommonConfig.AllowOrigins = []*url.URL{{Scheme: "*", Host: "*"}}
s.CommonConfig.AllowHeaders = []string{"*"}
} else {
for _, addr := range controllerAddresses {
// Add controller address to allow origins for console requests.
// The console is run on `localhost` so we replace 127.0.0.1 with localhost.
if addr.Hostname() == "127.0.0.1" {
addr.Host = "localhost" + ":" + addr.Port()
}
s.CommonConfig.AllowOrigins = append(s.CommonConfig.AllowOrigins, addr)
}
}

provisionerAddresses := make([]*url.URL, 0, s.Provisioners)
Expand Down

0 comments on commit 309be0e

Please sign in to comment.