Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
riojack opened this issue Aug 30, 2018 · 1 comment

Comments

@riojack
Copy link

riojack commented Aug 30, 2018

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.

@suddi
Copy link
Owner

suddi commented May 19, 2020

Thanks for the report.

But this does seem to be working. I have added another integration test to validate this, please see:
https://github.com/suddi/claudia-local-api/blob/master/test/index.js#L995

@github-staff github-staff deleted a comment from roccozs May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants