Skip to content

Commit 40274ca

Browse files
authored
Merge pull request #26 from mbramson/add-corsica
Add Corsica for CORS
2 parents 30249ca + d37d01b commit 40274ca

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
defmodule <%= @project_name_camel_case %>Web.CORS do
2+
use Corsica.Router,
3+
origins: ["http://localhost:3000", ~r{^https?://(.*\.?)\.com$}],
4+
allow_credentials: true,
5+
allow_headers: ["content-type"],
6+
log: [rejected: :debug, invalid: :debug, accepted: :debug],
7+
max_age: 600
8+
9+
resource "/*", origins: "*"
10+
end

template/$PROJECT_NAME$/lib/$PROJECT_NAME$_web/endpoint.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ defmodule <%= @project_name_camel_case %>Web.Endpoint do
3636
key: "_<%= @project_name %>_key",
3737
signing_salt: "lU5fdejS"
3838

39+
plug <%= @project_name_camel_case %>Web.CORS
3940
plug <%= @project_name_camel_case %>Web.Router
4041

4142
@doc """

template/$PROJECT_NAME$/mix.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ defmodule <%= @project_name_camel_case %>.Mixfile do
4141
{:guardian, "~> 0.14.5"},
4242
{:comeonin, "~> 4.0"},
4343
{:bcrypt_elixir, "~> 0.12.0"},
44+
{:corsica, "~> 1.0"},
4445
{:ex_machina, "~> 2.0", only: :test}]
4546
end
4647

0 commit comments

Comments
 (0)