diff --git a/pkg/api/endpoints.go b/pkg/api/endpoints.go
index e0cd9a9b270423efe2fb1c47c87743aba9ce566b..ebf219749e694950850e0510f3fc2e8d99e24505 100644
--- a/pkg/api/endpoints.go
+++ b/pkg/api/endpoints.go
@@ -69,18 +69,21 @@ func sortEndpoints[T m.Bridge | m.Gateway](cc string, endpoints []*T, locations
 	return result, nil
 }
 
-func createLocationTree[T m.Bridge | m.Gateway](endpoints []*T, locationWeights map[string]float64) *rbt.Tree[float64, []wr.Choice[*T]] {
-	tree := rbt.New[float64, []wr.Choice[*T]]()
+func createLocationTree[T m.Bridge | m.Gateway](endpoints []*T, locationWeights map[string]float64) *rbt.Tree[float64, []wr.Choice[T]] {
+	tree := rbt.New[float64, []wr.Choice[T]]()
 	for _, endpoint := range endpoints {
-		var list []wr.Choice[*T]
+		if endpoint == nil {
+			continue
+		}
+		var list []wr.Choice[T]
 		found := false
 		locationWeight := locationWeights[getLocation(endpoint)]
 		if list, found = tree.Get(locationWeight); !found {
 			// TODO: we want to set weights per gateways, so that gateways with higher capacities
 			// are priotized, the wr.Choice wrapper is a preparation for that
-			list = []wr.Choice[*T]{{Item: endpoint, Weight: 1}}
+			list = []wr.Choice[T]{{Item: *endpoint, Weight: 1}}
 		} else {
-			list = append(list, wr.Choice[*T]{Item: endpoint, Weight: 1})
+			list = append(list, wr.Choice[T]{Item: *endpoint, Weight: 1})
 		}
 		tree.Put(locationWeight, list)
 	}