diff --git a/src/invidious/routes/before_all.cr b/src/invidious/routes/before_all.cr index 474917c7..8d899fa1 100644 --- a/src/invidious/routes/before_all.cr +++ b/src/invidious/routes/before_all.cr @@ -54,7 +54,11 @@ module Invidious::Routes::BeforeAll current_companion = env.request.cookies[CONFIG.server_id_cookie_name].value.try &.to_i rescue working_ends = BackendInfo.get_working_ends - current_companion = working_ends.sample + if !working_ends.empty? + current_companion = working_ends.sample + else + current_companion = rand(CONFIG.invidious_companion.size) + end end if current_companion > CONFIG.invidious_companion.size