An Elixir Plug-based CORS middleware for Phoenix Framework.
The package can be installed by adding ex_cors
to your list of dependencies in mix.exs
:
def deps do
[
{:ex_cors, "~> 0.2"},
# ...
]
end
After you're done, run mix deps.get
in your terminal to fetch and compile all dependencies.
ex_cors
is intended to work with Phoenix.Enpoint
. The only thing you have to do in order to make it working is to modify your_app/lib/your_app/web/endpoint.ex
as follows:
defmodule YourApp.Endpoint do
use Phoenix.Enpoint, otp_app: :your_app
# ...
plug ExCors.AllowCorsRequests
plug YourApp.Router
# ...
end