GET vs POST

Dear all,

I have an issue with a Phoenix application that replicates the Rumbl sessions from the “Programing Elixir > 1.6” book.

I have an older version where session employs POST messages and log in/out works well.

Output is like that when logging out:

[info] POST /sessions/1
[debug] Processing with ScoutWeb.SessionController.delete/2
  Parameters: %{"_csrf_token" => "fhc5fCoVBENTFVR-ei8gRwArdRBtYyZd6ZMIyCwtjdfLJpe2Ye2x4Psh", "_method" => "delete", "id" => "1"}
  Pipelines: [:browser]
[debug] QUERY OK source="users" db=0.5ms idle=1283.6ms
SELECT u0."id", u0."name", u0."username", u0."password_hash", u0."inserted_at", u0."updated_at" FROM "users" AS u0 WHERE (u0."id" = $1) [1]
[info] Sent 302 in 1ms
[info] GET /
[debug] Processing with ScoutWeb.PageController.index/2
  Parameters: %{}
  Pipelines: [:browser]

I have pretty much identical Elixir code (at least to the best of my knowledge) for a new project (assets javascript code differs) where instead of POST, GET messages are exchanged.

In this project, when logging out I am getting:

[info] GET /sessions/1
[debug] ** (Phoenix.Router.NoRouteError) no route found for GET /sessions/1 (ScoutWeb.Router)
    (scout 0.1.0) lib/phoenix/router.ex:402: ScoutWeb.Router.call/2
    (scout 0.1.0) lib/scout_web/endpoint.ex:1: ScoutWeb.Endpoint.plug_builder_call/2
    (scout 0.1.0) lib/plug/debugger.ex:132: ScoutWeb.Endpoint."call (overridable 3)"/2
    (scout 0.1.0) lib/scout_web/endpoint.ex:1: ScoutWeb.Endpoint.call/2
    (phoenix 1.5.6) lib/phoenix/endpoint/cowboy2_handler.ex:65: Phoenix.Endpoint.Cowboy2Handler.init/4
    (cowboy 2.8.0) /Users/bdarla/dev/mygithub/2020/november/elixir/scout/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
    (cowboy 2.8.0) /Users/bdarla/dev/mygithub/2020/november/elixir/scout/deps/cowboy/src/cowboy_stream_h.erl:300: :cowboy_stream_h.execute/3
    (cowboy 2.8.0) /Users/bdarla/dev/mygithub/2020/november/elixir/scout/deps/cowboy/src/cowboy_stream_h.erl:291: :cowboy_stream_h.request_process/3
    (stdlib 3.13.2) proc_lib.erl:226: :proc_lib.init_p_do_apply/3

Does anyone know what causes this difference and instead of POST messages, GET messages are sent?

Thanks in advance for your help!

:wave:

Does your client code include phoenix_html package? It’s the one that modifies click event and replaces the http method used if one is provided.

2 Likes