diff --git a/src/invidious/routes/before_all.cr b/src/invidious/routes/before_all.cr index b1dc421a..13fde99b 100644 --- a/src/invidious/routes/before_all.cr +++ b/src/invidious/routes/before_all.cr @@ -67,9 +67,11 @@ module Invidious::Routes::BeforeAll frame_ancestors = "'none'" end + scheme = env.request.headers["X-Forwarded-Proto"]? || ("https" if CONFIG.https_only) || "http" + env.set "scheme", scheme + # TODO: Remove style-src's 'unsafe-inline', requires to remove all # inline styles (, style=" [..] ") - scheme = env.request.headers["X-Forwarded-Proto"]? || ("https" if CONFIG.https_only) || "http" env.response.headers["Content-Security-Policy"] = { "default-src 'none'", "script-src 'self'", diff --git a/src/invidious/views/channel.ecr b/src/invidious/views/channel.ecr index a64088a2..153df707 100644 --- a/src/invidious/views/channel.ecr +++ b/src/invidious/views/channel.ecr @@ -3,6 +3,7 @@ author = HTML.escape(channel.author) channel_profile_pic = URI.parse(channel.author_thumbnail).request_target host = env.request.headers["Host"] + scheme = env.get("scheme") relative_url = case selected_tab @@ -32,15 +33,15 @@ <%- if selected_tab.videos? -%> - + - + - + - + <%- end -%> diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr index 73bb6f39..4599f45a 100644 --- a/src/invidious/views/template.ecr +++ b/src/invidious/views/template.ecr @@ -110,6 +110,7 @@ if CONFIG.invidious_companion.present? current_backend = env.get?("current_companion").try &.as(Int32) domain = env.get?("domain").try &.as(Bool) + scheme = env.get("scheme") status = BackendInfo.get_status %>
@@ -117,7 +118,6 @@ <% if domain %> <% CONFIG.invidious_companion.each_with_index do | companion, index | %> <% is_current_backend_host = companion.domain == env.request.headers["Host"] %> - <% scheme = env.request.headers["X-Forwarded-Proto"]? || ("https" if CONFIG.https_only) || "http" %> display: inline-block;"> Backend<%= HTML.escape((index + 1).to_s) %> <%= HTML.escape(companion.note) %> +<% scheme = env.get("scheme") %> <% content_for "header" do %> - + "> - + - + - + - + - - + +