POST requests are being received as GET requests

I have a simple tunnel setup in Python which is supposed to receive requests on a custom domain and tunnel them to my localhost:8000.
The localhost works perfectly, its able to receive both GET and POST requests and respond accordingly. Most of the setup works, meaning I can send requests to my domain and have them be tunneled down to my localhost/webserver, but everytime I send a POST request to the domain its handled as a GET request in the end.
Since it works perfectly when I send the POST request straight to the localhost, im assuming it has something to do with either the configuration or some Cloudflare settings.

Hi there,

It sounds like there may be an issue with the configuration of your Cloudflare Tunnel or the way the requests are being forwarded. To troubleshoot this issue, please follow these steps:

  1. Ensure that your cloudflared tunnel configuration file (config.yml) does not contain any rules that change the method of incoming requests.
  2. Check your Cloudflare dashboard for any Page Rules or Transform Rules that might be altering the request method from POST to GET.
  3. Verify that your web server is correctly configured to handle POST requests on the path you’re testing.
  4. If you’re using a service worker or Cloudflare Workers, ensure that they’re not modifying the request method.
  5. Test the POST request directly to your tunnel URL (usually something like https://<your-tunnel-id> to see if the issue persists without involving the custom domain.

I hope this helps,

Feel free to reach back to us in case the issue remains after all these verifications.

1 Like

I found the solution.
If you’re running a HTTP webserver on your localhost: instead of a HTTPS, then make sure that your “Always use HTTPS” setting is disabled.

You can find the setting here:

Home → Websites → (Choose website) → SSL/TLS → Edge Certificates → (Scroll Down) → Always use HTTPS (Disable or Enable depending on if you use HTTPS or not)

Make sure to restart the tunnel and webserver afterwards.

Your description suggests Cloudflare did not change the request but you sent an HTTP request which Cloudflare redirected to HTTPS and your browser did send a GET request. If you want to use HTTP, you certainly must not redirect to HTTPS.

However, a restart is not necessary.

1 Like

Not entirely. I send a HTTP POST request, which cloudflare redirected to HTTPS, but when it did so it also changed the POST to GET which is slightly weird.
And yeah you definently shouldnt redirect to HTTPS when trying to use HTTP :sweat_smile:
But i do think the restart is necessary, because when i changed the settings while the tunnel was open and i then send a request, i would always get Error 502 - Bad gateway. But it works after you quickly restart the tunnel.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.