diff --git a/src/invidious/config.cr b/src/invidious/config.cr index e1d51e44..5cee4012 100644 --- a/src/invidious/config.cr +++ b/src/invidious/config.cr @@ -106,6 +106,8 @@ class Config property materialious_domain : String? # Alternative domains. You can add other domains, like TOR and I2P addresses property alternative_domains : Array(String) = [] of String + # Backend domains. Domains for numbered backends + property backend_domains : Array(String) = [] of String # Subscribe to channels using PubSubHubbub (requires domain, hmac_key) property use_pubsub_feeds : Bool | Int32 = false diff --git a/src/invidious/routes/login.cr b/src/invidious/routes/login.cr index 4c5446f8..df55d9a8 100644 --- a/src/invidious/routes/login.cr +++ b/src/invidious/routes/login.cr @@ -64,6 +64,8 @@ module Invidious::Routes::Login # TOR or I2P address if alt = CONFIG.alternative_domains.index(env.request.headers["Host"]) env.response.cookies["SID"] = Invidious::User::Cookies.sid(CONFIG.alternative_domains[alt], sid) + elsif alt = CONFIG.backend_domains.index(env.request.headers["Host"]) + env.response.cookies["SID"] = Invidious::User::Cookies.sid(CONFIG.backend_domains[alt], sid) else env.response.cookies["SID"] = Invidious::User::Cookies.sid(CONFIG.domain, sid) end @@ -170,6 +172,8 @@ module Invidious::Routes::Login # TOR or I2P address if alt = CONFIG.alternative_domains.index(env.request.headers["Host"]) env.response.cookies["SID"] = Invidious::User::Cookies.sid(CONFIG.alternative_domains[alt], sid) + elsif alt = CONFIG.backend_domains.index(env.request.headers["Host"]) + env.response.cookies["SID"] = Invidious::User::Cookies.sid(CONFIG.backend_domains[alt], sid) else env.response.cookies["SID"] = Invidious::User::Cookies.sid(CONFIG.domain, sid) end diff --git a/src/invidious/routes/preferences.cr b/src/invidious/routes/preferences.cr index 5d3dd9b7..3e415986 100644 --- a/src/invidious/routes/preferences.cr +++ b/src/invidious/routes/preferences.cr @@ -228,6 +228,8 @@ module Invidious::Routes::PreferencesRoute # TOR or I2P address if alt = CONFIG.alternative_domains.index(env.request.headers["Host"]) env.response.cookies["PREFS"] = Invidious::User::Cookies.prefs(CONFIG.alternative_domains[alt], preferences) + elsif alt = CONFIG.backend_domains.index(env.request.headers["Host"]) + env.response.cookies["PREFS"] = Invidious::User::Cookies.prefs(CONFIG.backend_domains[alt], preferences) else env.response.cookies["PREFS"] = Invidious::User::Cookies.prefs(CONFIG.domain, preferences) end @@ -269,6 +271,8 @@ module Invidious::Routes::PreferencesRoute # TOR or I2P address if alt = CONFIG.alternative_domains.index(env.request.headers["Host"]) env.response.cookies["PREFS"] = Invidious::User::Cookies.prefs(CONFIG.alternative_domains[alt], preferences) + elsif alt = CONFIG.backend_domains.index(env.request.headers["Host"]) + env.response.cookies["PREFS"] = Invidious::User::Cookies.prefs(CONFIG.backend_domains[alt], preferences) else env.response.cookies["PREFS"] = Invidious::User::Cookies.prefs(CONFIG.domain, preferences) end diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr index 0079ed61..d5f0d1eb 100644 --- a/src/invidious/views/template.ecr +++ b/src/invidious/views/template.ecr @@ -1,7 +1,8 @@ <% locale = env.get("preferences").as(Preferences).locale dark_mode = env.get("preferences").as(Preferences).dark_mode - current_backend = env.request.cookies[CONFIG.server_id_cookie_name]?.try &.value + current_backend = env.request.cookies[CONFIG.server_id_cookie_name]?.try &.value || env.request.headers["Host"] + current_external_videoplayback_proxy = Invidious::HttpServer::Utils.get_external_proxy() %> @@ -106,6 +107,7 @@ <% if !CONFIG.backends.empty? %> + <% if !CONFIG.backend_domains.includes?(env.request.headers["Host"]) %>
Switch Backend: <% CONFIG.backends.each do | backend | %> @@ -128,6 +130,7 @@ <% end %>
<% end %> + <% end %> <% if CONFIG.banner %>
@@ -311,6 +314,9 @@