[error] ** (UndefinedFunctionError) function CorsPlug.init/1 is undefined (module CorsPlug is not available)

I want to add CORS into my phoenix project, and I added plug CORSPlug, origin: "*", and corsplug into my mix.exs, and run the mix deps.get, I checked that CORSPlug indeed exist, and it seems CorsPlug.init function defined in the CORSPlug module, I have no idea how to solve it.

1 Like

As I can’t find corsplug on hex.pm, can you please share what exactly you added to your dependency list and where you added the plug line?

2 Likes

you can check this article https://abulasar.com/installing-cors-in-elixir-phoenix-application, and I solved the error just by killing the mix phx.server, and restart it.

1 Like

That article seems to talk about cors_plug, not corsplug.

Yes, if you made changes to the deps you need to rebuild. To be honest, I got into the habbit to always shut down the server if I am not working on controllers, views or liveviews.

3 Likes