cors_plug icon indicating copy to clipboard operation
cors_plug copied to clipboard

Headers cannot be set dynamically

Open rm116 opened this issue 3 years ago • 0 comments

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.

rm116 avatar Aug 31 '22 12:08 rm116