I’m trying to set up Plug.Static in router.ex using Phoenix 1.3.
When using the format that static.ex inline documentation shows, i.e:
defmodule AppWeb.Router do
...
plug Plug.Static,
at: "/uploads",
from: {:app_name, "uploads"},
only: ~w(images robots.txt)
...
end
compilation fails with the message:
plug must be defined inside a pipeline
That’s expected; however, when attempting to define in a pipeline like this:
defmodule AppWeb.Router do
...
pipeline :static do
plug Plug.Static,
at: "/uploads",
from: {:app_name, "uploads"},
only: ~w(images robots.txt)
end
scope "/uploads", AppWeb do
pipe_through :static
end
...
end
the route is not found and none of the files in the directory are served when requested.
So I guess I’ve got some incorrect assumptions at work and so my question is, how does one configure router.ex to use Plug.Static in Phoenix 1.3?
Thanks for your time & help!






















