diff --git a/src/invidious/routes/video_playback.cr b/src/invidious/routes/video_playback.cr index 26852d068..f098f8216 100644 --- a/src/invidious/routes/video_playback.cr +++ b/src/invidious/routes/video_playback.cr @@ -164,11 +164,13 @@ module Invidious::Routes::VideoPlayback env.response.headers["Access-Control-Allow-Origin"] = "*" if location = resp.headers["Location"]? - location = URI.parse(location) - location = "#{location.request_target}&host=#{location.host}#{region ? "®ion=#{region}" : ""}" + url = Invidious::HttpServer::Utils.proxy_video_url(location, region: region) - env.redirect location - break + if title = query_params["title"]? + url = "#{url}&title=#{URI.encode_www_form(title)}" + end + + return env.redirect url end if title = query_params["title"]?