Files
nadeko_invidious/src/invidious/routes/backend_switcher.cr
Fijxu caa2273bf2
Some checks are pending
Build and release container directly from master / release (push) Waiting to run
Invidious CI / build - crystal: ${{ matrix.crystal }}, stable: ${{ matrix.stable }} (1.12.1, true) (push) Waiting to run
Invidious CI / build - crystal: ${{ matrix.crystal }}, stable: ${{ matrix.stable }} (1.13.2, true) (push) Waiting to run
Invidious CI / build - crystal: ${{ matrix.crystal }}, stable: ${{ matrix.stable }} (1.14.0, true) (push) Waiting to run
Invidious CI / build - crystal: ${{ matrix.crystal }}, stable: ${{ matrix.stable }} (1.15.0, true) (push) Waiting to run
Invidious CI / build - crystal: ${{ matrix.crystal }}, stable: ${{ matrix.stable }} (nightly, false) (push) Waiting to run
Invidious CI / build-docker (push) Waiting to run
Invidious CI / build-docker-arm64 (push) Waiting to run
Invidious CI / lint (push) Waiting to run
fix(backend switcher): pass referer in URL
Closes https://git.nadeko.net/Fijxu/invidious/issues/109

This will allow browsers that by default set the referer to the same
page to tracking via the referer header. IceCat browser does this.
2025-05-08 20:27:40 -04:00

17 lines
469 B
Crystal

{% skip_file if flag?(:api_only) %}
module Invidious::Routes::BackendSwitcher
def self.switch(env)
referer = get_referer(env, unroll: false)
backend_id = env.params.query["backend_id"]?.try &.to_i
if backend_id.nil?
return error_template(400, "Backend ID is required")
end
env.response.cookies[CONFIG.server_id_cookie_name] = Invidious::User::Cookies.server_id(env.request.headers["Host"], backend_id)
env.redirect referer
end
end