Fix LiveDashboard redirect not working when user added a path segment

/phoenix/live_dashboard -> /pleroma/live_dashboard would work

/phoenix/live_dashboard/ecto_stats -> /pleroma/live_dashboard/ecto_stats
would not work and instead reply with FE.
This commit is contained in:
Phantasm 2026-02-16 17:04:00 +01:00
commit 699a7e57e8
No known key found for this signature in database
GPG key ID: 2669E588BCC634C8
4 changed files with 19 additions and 3 deletions

View file

@ -0,0 +1 @@
Fix /phoenix/live_dashboard redirect not working when user added a path segment

View file

@ -29,9 +29,18 @@ defmodule Pleroma.Web.Fallback.RedirectController do
) )
end end
def live_dashboard(conn, _params) do def live_dashboard(conn, %{"path" => path}) do
query_params = conn.query_string
redirect_path =
if query_params == "" do
"/pleroma/live_dashboard/#{path}"
else
"/pleroma/live_dashboard/#{path}?#{query_params}"
end
conn conn
|> redirect(to: "/pleroma/live_dashboard") |> redirect(to: redirect_path)
end end
def redirector(conn, _params, code \\ 200) do def redirector(conn, _params, code \\ 200) do

View file

@ -1088,7 +1088,7 @@ defmodule Pleroma.Web.Router do
get("/:maybe_nickname_or_id", RedirectController, :redirector_with_meta) get("/:maybe_nickname_or_id", RedirectController, :redirector_with_meta)
match(:*, "/api/pleroma/*path", LegacyPleromaApiRerouterPlug, []) match(:*, "/api/pleroma/*path", LegacyPleromaApiRerouterPlug, [])
get("/api/*path", RedirectController, :api_not_implemented) get("/api/*path", RedirectController, :api_not_implemented)
get("/phoenix/live_dashboard", RedirectController, :live_dashboard) get("/phoenix/live_dashboard/*path", RedirectController, :live_dashboard)
get("/*path", RedirectController, :redirector_with_preload) get("/*path", RedirectController, :redirector_with_preload)
options("/*path", RedirectController, :empty) options("/*path", RedirectController, :empty)

View file

@ -79,6 +79,12 @@ defmodule Pleroma.Web.FallbackTest do
test "GET /phoenix/live_dashboard -> /pleroma/live_dashboard", %{conn: conn} do test "GET /phoenix/live_dashboard -> /pleroma/live_dashboard", %{conn: conn} do
assert redirected_to(get(conn, "/phoenix/live_dashboard")) =~ "/pleroma/live_dashboard" assert redirected_to(get(conn, "/phoenix/live_dashboard")) =~ "/pleroma/live_dashboard"
assert redirected_to(get(conn, "/phoenix/live_dashboard/")) =~ "/pleroma/live_dashboard/"
end
test "GET /phoenix/live_dashboard/* -> /pleroma/live_dashboard/*", %{conn: conn} do
assert redirected_to(get(conn, "/phoenix/live_dashboard/ecto_stats?nav=diagnose")) =~
"/pleroma/live_dashboard/ecto_stats?nav=diagnose"
end end
test "OPTIONS /*path", %{conn: conn} do test "OPTIONS /*path", %{conn: conn} do