Client Request body Empty
Background:
I'm using a cloudflare tunnel. I'm writing an API.
Problem:
When I try to reach the API endpoints using my domain name as host, through the tunnel, I don't get the request body from client at all!
This is present in neither the logs that the API backend generates, nor the logs stream on cloudflare tunnels log stream dashboard.
The API backend receives and sends responses correctly when I access it on localhost directly.
Example:
vs
Logs Generated:
vs
Expected:
The backend through tunnel receives full request body, like it happens when not using the tunnel.
7 Replies
Youre sending a Get request with a POST body. While this isn‘t explicitly diallowed in the Http spec, it‘s mostly not supported and you should use POST etc for that
I tried all 4 combinations of JSON and FORM-BODY with GET and POST
Should be Post, wouldn‘t try further with Get. Your server doesn‘t receive any Post body data?
You don't need to specify the content-length either, it's auto-generated, manually specifying is likely just to cause you issues, ex:
curl -X POST https://127.0.0.1/list_users \ -H "Content-Type: application/json" \ -d '{"user_type": "student"}' -vvv
Tried that as well
I know it's auto generated, but just to be sure, I added that.
I tried some online API testing tools as well
Bump
I'd get the logs both from Cloudflare tunnel and from your backend when you send it as POST request and don't manually specify the content-length
Cloudflare logs don't show the form body or json, whichever one I set
The server is up and always running if anyone wants to give it a shot
Curl request I'm using for testing.
This is a big blocker for me.
check https://api.brightprogrammer.in/docs for docs
This is how it looks in cloudflare zero-trust tunnel logs
The problem seems to be in cloudflare itself. This is surely a bug. I checked with ngrok and it works flawlessly