Search code examples
reactjsexpressreduxfiddler

PATCH request doesn't seem to reach Express.js server


I'm writing (as an exercise) an Express + React application that manages a To Do list. You can see the code on GitHub.

Each task has a Done button that sends a PATCH request to the server. However, when I press it I get a 400 Bad Request.

Furthermore,

  1. Even though the server is configured to log every request, these PATCH requests don't appear in the log output.
  2. When Fiddler is running, the PATCH requests suddenly begin to work just fine! As soon as I close Fiddler, I start to get 400 again.

The same behavior is observed in Chrome, Edge, and Firefox.

Any ideas?


Solution

  • I found the cause: I spelled patch in lowercase. Apparently, Express only recognizes PATCH in uppercase.

    Strangely enough, this idiosyncrasy doesn't apply to other methods like post and delete, which are recognized also in lowercase.

    Fiddler probably converts all method names to uppercase before forwarding the requests to the server.