0
votes

I'm an elixir noob migrating from rails. I cant start the server. I started a --no-html --no-brunch project. I done nothing but start the project and gave the below error on the page

Phoenix.Router.NoRouteError at GET / no route found for GET / (PhoenixReactChat.Router)

and it shows my standard router.ex on the page

    defmodule PhoenixReactChat.Router do .   
      use PhoenixReactChat.Web, :router

      pipeline :api do
        plug :accepts, ["json"]
      end

      scope "/api", PhoenixReactChat do
        pipe_through :api
      end
    end

Using my Rails mind I'd add something referring to the root like root "home#index" in this file right? How would I go about doing this? Also the documentation doesn't include any lines of code like this to get the server started.

edit: That said I'm also following an old tutorial for my project.(https://medium.com/@benhansen/lets-build-a-slack-clone-with-elixir-phoenix-and-react-part-1-project-setup-3252ae780a1) some further digging tells me this error is to be expected due to the set up. (https://developer.epages.com/blog/2017/02/09/programming-beyond-the-comfort-zone-the-phoenix-framework.html)

2

2 Answers

0
votes

It looks like you need to add a route to the controller that you want to handle for the path /.

There are a couple of ways to handle it. You should check out the Phoenix Routing guide. One of the ways to handle this is to add something like the following inside your api scope.:

scope "/api", PhoenixReactChat do
  pipe_through :api

  get "/", PageController, :index
end

You can also add the resources macro to to add an all of the RESTful functions within a controller to your routes as well.

0
votes

I didn't realize the no html nor branch option got rid of the page controller when i used it. I want to say to who ever downvoted me that we all start somewhere and undoubtedly someone will run into the same issue. Now when they google they'll know dont freak out things have changed since phoenix 1.2 (I'm not sure because 1.3 is my 1st step in). So tldr if you pick no html you wont be able check your server in your browser. You can still run it but you won't get the welcome page. You can still run iex from the server using iex -S mix phx.server and run tests on code just fine.