How to set a default route for /admin
#723
-
Hello, First, thank you for making this great package - Perhaps I've missed this info in the guide - but how can we set a default route for the admin scope ? When I access I'm still farely new to the Elixir/Phx world so bear with me if I am missing something obvious. Thanks for any insight. Aaron |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hey @aaronzomback! You can create a (redirect) controller for this use case. In your scope "/admin", MyAppWeb do
get "/", RedirectController, :redirect_to_posts
end For example, in defmodule MyAppWeb.RedirectController do
use MyAppWeb, :controller
def redirect_to_posts(conn, _params) do
conn
|> Phoenix.Controller.redirect(to: ~p"/admin/posts")
|> Plug.Conn.halt()
end
end That's it! |
Beta Was this translation helpful? Give feedback.
Hey @aaronzomback!
You can create a (redirect) controller for this use case.
In your
router.ex
file:For example, in
my_app_web/controller
create a file namedredirect_controller.ex
:That's it!