mschae / cors_plug

An Elixir Plug to add CORS.
https://hex.pm/packages/cors_plug
Other
404 stars 75 forks source link

Headers cannot be set dynamically #93

Open rm116 opened 2 years ago

rm116 commented 2 years ago

endpoint.ex :

import AppName.ConfigHelpers
...
plug CORSPlug, origin: cors_origins(), headers: cors_headers()

Inside ConfigHelpers :

def cors_origins() do
    if System.get_env("ENV") == "production" do
      [@origin_regex, "https://other.com"]
    else
      ["*"]
    end
  end

def cors_headers() do
    ["test_wrong_header"]
  end

The origins are good, but I have an impression that all headers are allowed, If I deploy with that list [“test_wrong_header”], the request is accepted.