@@ -87,6 +87,28 @@ defmodule Phoenix.LiveDashboardTest.Router do
8787 live_dashboard "/dashboard" ,
8888 metrics: Phoenix.LiveDashboardTest.Telemetry
8989
90+ live_dashboard "/parent_cookie_domain" ,
91+ request_logger_cookie_domain: :parent ,
92+ live_session_name: :cookie_dashboard
93+ end
94+
95+ # we only really support one live dashboard per router,
96+ # and some tests rely on correct redirect paths that wouldn't work with multiple dashboards;
97+ # as a workaround we forward all non matching requests to a separate router
98+ forward "/" , Phoenix.LiveDashboardTest.RouterConfig
99+ end
100+
101+ defmodule Phoenix.LiveDashboardTest.RouterConfig do
102+ use Phoenix.Router
103+ import Phoenix.LiveDashboard.Router
104+
105+ pipeline :browser do
106+ plug :fetch_session
107+ end
108+
109+ scope "/" , ThisWontBeUsed , as: :this_wont_be_used do
110+ pipe_through :browser
111+
90112 live_dashboard "/config" ,
91113 live_socket_path: "/custom/live" ,
92114 csp_nonce_assign_key: % {
@@ -100,10 +122,6 @@ defmodule Phoenix.LiveDashboardTest.Router do
100122 metrics_history: { TestHistory , :test_data , [ ] } ,
101123 request_logger_cookie_domain: "my.domain" ,
102124 live_session_name: :config_dashboard
103-
104- live_dashboard "/parent_cookie_domain" ,
105- request_logger_cookie_domain: :parent ,
106- live_session_name: :cookie_dashboard
107125 end
108126end
109127
0 commit comments