Skip to content

Commit

Permalink
Adds tallysmartins to cors origins (#40)
Browse files Browse the repository at this point in the history
* Adds tallysmartins to cors origins

Signed-off-by: Tallys Martins <tallysmartins@gmail.com>

* Adds staging environment

Signed-off-by: Tallys Martins <tallysmartins@gmail.com>
  • Loading branch information
tallysmartins authored and PragTob committed Aug 1, 2018
1 parent 34eee07 commit 993d459
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions config/staging.exs
@@ -0,0 +1,6 @@
use Mix.Config

# Any custom change to be tested in a production like environment must be added here
import_config "prod.exs"

config :elixir_bench, ElixirBenchWeb.Endpoint, origins: [~r/tallysmartins.github.io$/]
7 changes: 6 additions & 1 deletion lib/elixir_bench_web/endpoint.ex
Expand Up @@ -28,9 +28,14 @@ defmodule ElixirBenchWeb.Endpoint do
plug Plug.MethodOverride
plug Plug.Head

allowed_origins =
:elixir_bench
|> Application.get_env(ElixirBenchWeb.Endpoint, [])
|> Keyword.get(:origins, [])

plug Corsica,
max_age: 600,
origins: [~r/localhost:\d+$/, ~r/elixirbench.org$/],
origins: [~r/localhost:\d+$/, ~r/elixirbench.org$/] ++ allowed_origins,
allow_headers: ~w(accept content-type origin)

plug ElixirBenchWeb.Router
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Expand Up @@ -8,7 +8,7 @@ defmodule ElixirBench.Mixfile do
elixir: "~> 1.4",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:phoenix] ++ Mix.compilers(),
start_permanent: Mix.env() == :prod,
start_permanent: Mix.env() == :prod || Mix.env() == :staging,
aliases: aliases(),
test_coverage: [tool: ExCoveralls],
preferred_cli_env: [
Expand Down
5 changes: 5 additions & 0 deletions rel/config.exs
Expand Up @@ -39,6 +39,11 @@ environment :prod do
set cookie: :"?HJ`Ukk;))_nwy4>j>@bPXc6oNSZ==ivI9kF96,63D)S]lkI~tT^NJL]TN@Or5*4"
end

environment :staging do
set include_erts: true
set include_src: false
end

# You may define one or more releases in this file.
# If you have not set a default release, or selected one
# when running `mix release`, the first release in the file
Expand Down

0 comments on commit 993d459

Please sign in to comment.