I’ve been playing around with Phoenix for a personal project. Phoenix by default comes setup with a basic PageController. I wanted to use Elm’s Navigation package to handle routing on my Elm app.

With the default setup, Phoenix will attempt to serve the route, ending in a 404. I had to change my router.ex to the following to allow any path to defer to the PageController.index function:

defmodule AppliedAt.Router do
  use AppliedAt.Web, :router
 
  scope "/", AppliedAt do
    pipe_through :browser # Use the default browser stack
 
    get "/*path", PageController, :index # <-- Allows any number of path items
  end
end

This should work for any router in JavaScript, Elm, or < insert language here > 😄.