aesmail / kaffy

Powerfully simple admin package for phoenix applications
https://kaffy.fly.dev/admin/
MIT License
1.3k stars 153 forks source link

[BUG] Unable to update records (404 error) #264

Closed jcelliott closed 1 year ago

jcelliott commented 1 year ago

Versions Used Kaffy: 0.9.4 Phoenix: 1.6.16 Elixir: 1.14.2

What's actually happening?

When I click "Save" to update a record I'm getting a 404 error. Looking at the network logs, it's trying to make a POST request to /:context/:resource/:id instead of a PUT request. I've tested on Firefox and Chrome to make sure it wasn't a browser issue.

[info] POST /admin/models/user/8a1af195-e606-4935-a39c-a7b38512dbcb
[info] Sent 404 in 7ms
[debug] Converted error Phoenix.Router.NoRouteError to 404 response

What should happen instead?

The record should be saved correctly. The frontend should be making a PUT request.

I see the router configuration here and the form configuration here, which both look correct to me. If anyone has pointers for somewhere else I should look please let me know.

a3kov commented 1 year ago

Make sure you have Plug.Parsers running before Plug.MethodOverride The override will not work without the parsed body available

jcelliott commented 1 year ago

@a3kov thank you for the suggestion! That was indeed the issue. We have a complicated Plug.Parsers configuration due to some proxy requests we're handling, but the net result was the _method parameter wasn't getting parsed before Plug.MethodOverride was called.