I want to run an angularJS front end with a phoenix backend for my site. I would like my root route to direct the user to a pre-built page in the static directory which contains my angular client and then use phoenix to run the API. I have done this in the past with ruby on rails by route matching like this:
get '/', to: redirect('/foobar.html')
Is there a way to do something similar with phoenix?
Not right now. You need to create a controller and then in the controller:
defmodule MyApp.RootController do
use MyApp.Web, :controller
plug :action
def index(conn, _params) do
redirect conn, to: "/foobar.html"
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With