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

Does anyone account this error(content-length mismatch)? #552

Open
ReginaLiang opened this issue Nov 29, 2024 · 10 comments
Open

Does anyone account this error(content-length mismatch)? #552

ReginaLiang opened this issue Nov 29, 2024 · 10 comments

Comments

@ReginaLiang
Copy link

I used the nextjs, then fetch api, will occur Request body length does not match content-length header.
How to fix it?

Thanks.

@bnusunny
Copy link
Contributor

@ReginaLiang Could you provide more details about how this error happened? The runtime version, the LWA version, the invoke mode, and how frequent did it happen?

@ReginaLiang
Copy link
Author

ReginaLiang commented Dec 17, 2024

@ReginaLiang Could you provide more details about how this error happened? The runtime version, the LWA version, the invoke mode, and how frequent did it happen?

Sure, I used lambda to deploy a nextjs app, and the runtime version is Nodejs 18, the LWA version is 0.8.4. Then there is an api gateway http api to call this lambda. HTTP API sets up a proxy for all requests. Finally, Nextjs application can run successfully, But when fetching the background API, it will report Request body length does not match content-length header. This problem only occurs in get requests, Post requests are fine. Can you provide some useful information? Many thanks!!!

@bnusunny
Copy link
Contributor

bnusunny commented Dec 17, 2024

@ReginaLiang can you provide more CloudWatch Logs related to the error message?

@ReginaLiang
Copy link
Author

@ReginaLiang can you provide more CloudWatch Logs related to the error message?

截屏2024-11-29 12 28 43

FYI, This error is from Lambda. Thanks.

@bnusunny
Copy link
Contributor

From these logs, it seems the next.js app was trying to send a GET request to another API and failed with the error Request body length does not match content-length header. Could you log the actual body lenthg and the content-length header before sending the request? Does this work on you local computer?

@ReginaLiang
Copy link
Author

From these logs, it seems the next.js app was trying to send a GET request to another API and failed with the error Request body length does not match content-length header. Could you log the actual body lenthg and the content-length header before sending the request? Does this work on you local computer?

Yes, It works fine on my local computer. and the body as follows:
截屏2024-11-29 11 54 22

@bnusunny
Copy link
Contributor

This is the Lambda payload. LWA will translate it into a HTTP request and send to your next.js web app. Could you add debug logging in your next.js web app to show the http request it received? Especially the content-length header and the actual body.

@ReginaLiang
Copy link
Author

This is the Lambda payload. LWA will translate it into a HTTP request and send to your next.js web app. Could you add debug logging in your next.js web app to show the http request it received? Especially the content-length header and the actual body.

In fact, my nextjs app does not receive any parameters from lambda, but simply requests other apis through fetch, Will this have an impact?

@bnusunny
Copy link
Contributor

Hmm, this doesn't seem like an issue with LWA. Could you share a simple example which can reproduce this issue?

@ReginaLiang
Copy link
Author

Hmm, this doesn't seem like an issue with LWA. Could you share a simple example which can reproduce this issue?

I will prepare a sample to reproduce this problem in my free time. I appreciate your help.

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