@@ -58,26 +58,31 @@ func (api *API) regions(rw http.ResponseWriter, r *http.Request) {
58
58
return
59
59
}
60
60
61
- proxyHealth := api .ProxyHealth .HealthStatus ()
62
- for _ , proxy := range proxies {
63
- if proxy .Deleted {
64
- continue
65
- }
66
-
67
- health , ok := proxyHealth [proxy .ID ]
68
- if ! ok {
69
- health .Status = proxyhealth .Unknown
61
+ // Only add additional regions if the proxy health is enabled.
62
+ // If it is nil, it is because the moons feature flag is not on.
63
+ // By default, we still want to return the primary region.
64
+ if api .ProxyHealth != nil {
65
+ proxyHealth := api .ProxyHealth .HealthStatus ()
66
+ for _ , proxy := range proxies {
67
+ if proxy .Deleted {
68
+ continue
69
+ }
70
+
71
+ health , ok := proxyHealth [proxy .ID ]
72
+ if ! ok {
73
+ health .Status = proxyhealth .Unknown
74
+ }
75
+
76
+ regions = append (regions , codersdk.Region {
77
+ ID : proxy .ID ,
78
+ Name : proxy .Name ,
79
+ DisplayName : proxy .DisplayName ,
80
+ IconURL : proxy .Icon ,
81
+ Healthy : health .Status == proxyhealth .Healthy ,
82
+ PathAppURL : proxy .Url ,
83
+ WildcardHostname : proxy .WildcardHostname ,
84
+ })
70
85
}
71
-
72
- regions = append (regions , codersdk.Region {
73
- ID : proxy .ID ,
74
- Name : proxy .Name ,
75
- DisplayName : proxy .DisplayName ,
76
- IconURL : proxy .Icon ,
77
- Healthy : health .Status == proxyhealth .Healthy ,
78
- PathAppURL : proxy .Url ,
79
- WildcardHostname : proxy .WildcardHostname ,
80
- })
81
86
}
82
87
83
88
httpapi .Write (ctx , rw , http .StatusOK , codersdk.RegionsResponse {
0 commit comments