Cannot get post parameter when using cors_plug

Hello guys,

I’m having trouble when I’m using cors_plug,
I have my front end app that uses elm to send GET or POST requests and uses preflight validation with OPTIONS request, I do get the translated post request but the parameters are empty.

I do not quite understand what’s the problem I think that the post request is sent in the body of the OPTIONS request and so the controller cannot get that body…
I followed the instructions of to install and initialize cors to handle the preflight validation.

If someone got an idea I will be more than thankeful.
Thanks for your time and attention.

Ps: If you need any detailed information about the router or controller you can get everything on my repo: or ask me on the topic I will be reactive.

Did you try it in dev mode, on your machine? If so, what did the Phoenix log/output look like?

1 Like

Thanks for your time mate !

In fact the problem was coming from my headers sent by the front-end it was not generating the right content-type as the server-side was only accepting json and the content-type sent were application/json json.

This was a pain to debug because the inspection made on the parameters sent was not called as the request were not even reaching the controllers logic.

But this is also due to the fact that I only have a 3 weeks background on elixir/phoenix…

So if anyone has the same problem check your requests headers and be sure that you allow them through CORSplug options !

If anyone’s interested in checking the project here is the link : aio-elm-elixir