I'm trying to configure cors for my Phoenix app - when I submit my API request I receive the response:
Access to XMLHttpRequest at 'http://localhost:4000/api/data' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
In my mix.exs file I include the dep: {:cors_plug, "~> 3.0"}
In my router.ex file I have:
pipeline :api do
plug :accepts, ["json"]
plug CORSPlug, origin: ~r/https?.*localhost.\d*/
forward "/", Absinthe.Plug, schema: DxAppRcWeb.Schema
end
Any ideas what I could be doing wrong?