phoenix icon indicating copy to clipboard operation
phoenix copied to clipboard

redirected_params(conn) gives an error when using forwarded routes

Open himangshuj opened this issue 1 year ago • 5 comments

Environment

  • Elixir version (elixir -v): Elixir 1.13.4 (compiled with Erlang/OTP 22)
  • Phoenix version (mix deps): 1.6.7
  • Operating system: Mac OS

Expected behavior

  assert %{id: id} = redirected_params(conn) should work for the controller for both forwarded and normal routes. 

Actual behavior

  assert %{id: id} = redirected_params(conn) fails when I put the controller under forwarded routes

Source of Bug

Phoenix.Router.route_info(router, "GET", path, host ) - this method gives an error because it ignores the script_name "admin" when cycling through the routes

 IO.inspect(Phoenix.Router.route_info(router, "GET", path, host )) ## errors out
 IO.inspect(Phoenix.Router.route_info(router, "GET", String.replace(path, "/admin",""), host )) ## admin is the forwarded prefix, this code works fine

himangshuj avatar Sep 03 '22 20:09 himangshuj