Skip to content

Commit 993d459

Browse files
tallysmartinsPragTob
authored andcommitted
Adds tallysmartins to cors origins (#40)
* Adds tallysmartins to cors origins Signed-off-by: Tallys Martins <[email protected]> * Adds staging environment Signed-off-by: Tallys Martins <[email protected]>
1 parent 34eee07 commit 993d459

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

config/staging.exs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
use Mix.Config
2+
3+
# Any custom change to be tested in a production like environment must be added here
4+
import_config "prod.exs"
5+
6+
config :elixir_bench, ElixirBenchWeb.Endpoint, origins: [~r/tallysmartins.github.io$/]

lib/elixir_bench_web/endpoint.ex

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,14 @@ defmodule ElixirBenchWeb.Endpoint do
2828
plug Plug.MethodOverride
2929
plug Plug.Head
3030

31+
allowed_origins =
32+
:elixir_bench
33+
|> Application.get_env(ElixirBenchWeb.Endpoint, [])
34+
|> Keyword.get(:origins, [])
35+
3136
plug Corsica,
3237
max_age: 600,
33-
origins: [~r/localhost:\d+$/, ~r/elixirbench.org$/],
38+
origins: [~r/localhost:\d+$/, ~r/elixirbench.org$/] ++ allowed_origins,
3439
allow_headers: ~w(accept content-type origin)
3540

3641
plug ElixirBenchWeb.Router

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ defmodule ElixirBench.Mixfile do
88
elixir: "~> 1.4",
99
elixirc_paths: elixirc_paths(Mix.env()),
1010
compilers: [:phoenix] ++ Mix.compilers(),
11-
start_permanent: Mix.env() == :prod,
11+
start_permanent: Mix.env() == :prod || Mix.env() == :staging,
1212
aliases: aliases(),
1313
test_coverage: [tool: ExCoveralls],
1414
preferred_cli_env: [

rel/config.exs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ environment :prod do
3939
set cookie: :"?HJ`Ukk;))_nwy4>j>@bPXc6oNSZ==ivI9kF96,63D)S]lkI~tT^NJL]TN@Or5*4"
4040
end
4141

42+
environment :staging do
43+
set include_erts: true
44+
set include_src: false
45+
end
46+
4247
# You may define one or more releases in this file.
4348
# If you have not set a default release, or selected one
4449
# when running `mix release`, the first release in the file

0 commit comments

Comments
 (0)