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

[now-node] Fix helpers when POST json has empty body #3177

Merged
merged 4 commits into from
Oct 21, 2019
Merged

Conversation

styfle
Copy link
Member

@styfle styfle commented Oct 21, 2019

The @now/node helpers json parsing is too strict and doesn't match the behavior of Express when an incoming request has { method: 'POST', Content-Type: 'application/json', body: '' }.

Instead of returning 400, this PR will continue with body = {} to match Express.

Fixes https://spectrum.chat/zeit/now/klarna-with-zeit-now~60852003-4db6-4ec4-a611-83b2349ece08

@styfle styfle marked this pull request as ready for review October 21, 2019 15:18
@lucleray
Copy link
Member

It looks like the unit tests need to be updated 🤔

@@ -78,13 +82,15 @@ function status(res: NowResponse, statusCode: number): NowResponse {
}

function setCharset(type: string, charset: string) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add a single line for these at the beginning of the file OR if the rule doesn't make sense for us, you can turn it off for the whole repo in eslintrc.json

Copy link
Member

@lucleray lucleray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 🙏

@kodiakhq kodiakhq bot merged commit d2cd4a3 into canary Oct 21, 2019
@kodiakhq kodiakhq bot deleted the empty-body-json branch October 21, 2019 15:45
TooTallNate pushed a commit that referenced this pull request Oct 21, 2019
The `@now/node` helpers json parsing is too strict and doesn't match the behavior of Express when an incoming request has `{ method: 'POST', Content-Type: 'application/json', body: '' }`.

Instead of returning 400, this PR will continue with `body = {}` to match Express.

Fixes https://spectrum.chat/zeit/now/klarna-with-zeit-now~60852003-4db6-4ec4-a611-83b2349ece08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants