Response cookies must be set using cowboy_req
eric0fw opened this issue · 1 comments
plug_cowboy
v2.7.0 is currently marked as incompatible with cowboy
v2.11.0.
It seems Cowboy has released an update (2.11), and that doesn't play nice with plug_cowboy
, which asks for the latest cowboy
(from what I can see). So today's build running with 2.11 doesn't work, but the build with 2.10 works fine.
Running mix phx.create
is broken out of the box. On initial load, you see the following error:
:invalid_header, :"Response cookies must be set using cowboy_req:set_resp_cookie/3,4."}
Yes this is due to Cowboy being more explicit in what is not allowed with regard to the set-cookie header. Setting it the way Plug does is wrong because the set-cookie header is special (it breaks the HTTP spec) and Cowboy cannot handle it like other headers. That it happened to work before is a coincidence and it likely could break in various ways. So the solution is to either use the appropriate functions or to set the resp_cookies
value directly in the Req
.
I don't know what needs to happen in Plug or Phoenix or other projects to make things work as I don't do Elixir. But both solutions above should work for all versions 2.x and probably even 1.x as well.