Skip to content

POSTing application/x-www-form-urlencoded data causes Claudia to skip parsing the key-values in the body #21

@riojack

Description

@riojack

Steps to reproduce

  1. Create a simple Claudia API with Claudia API Builder.
  2. Include a route that handles a POST request.
  3. Start the API with claudia-local-api --api-module ./entry_point_file.js.
  4. With cURL, Postman, Insomnia, or some REST tool, do a POST to the route from step 2 and give it a Content-Type of application/x-www-form-urlencoded then add a body of foo=bar&baz=45.
  5. In the request handler function request.post is an empty object. Expected request.post to equal { foo: "bar", baz: 45 }.

I think this is caused by using bodyParser.urlencoded(...), which will is middleware that will cause Express to parse the POST body into a JSON object before Claudia has a chance to handle it.

In the context of an AWS Lambda that is connected to API Gateway, this extra parsing step does not happen. Claudia gets the raw body as a string and not as a JSON object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions