Problem with POST requests

My iOS app makes POST requests to Google Cloud Run container which hosts my Django Rest Framework Project.

To add a layer of security I’ve set up public ESP (Extensible Service Proxy - Cloud Endpoints) to serve as a gateway for private Cloud Run Container. Basically, ESP does authentication before routing the request to private Cloud Run container.

All GET requests to ESP work fine: they successfully get routed to Cloud Run Container (for example when I request non existing /hello at www.example.com/hello, I get Django Debug 404)

However, for some reason, POST requests are not routed by ESP (for example I’m trying to access existing /upload at www.example.com/upload I get standard 404), and ESP logs show the request never made it to Cloud Run container.

I’ve tried disabling csrf, setting APPEND_SLASH to false, nothing seems to work. All POST requests result in 404.

Am I doing something wrong in Django?

All POST requests work fine if sent directly to Cloud Run Container

All testing done with Postman.

You aren’t running with DEBUG=True in production are you? :innocent:

This makes it really sound like the problem with ESP, rather than in Django anywhere.

I’ve never heard of ESP before but I checked its docs and it says it takes an Open API config file. Did you upload that, and does yours allow POST to your endpoints?

It’s not in production yet :)) I’m using DEBUG=True for the time being, while testing.

Yes, ESP takes OpenAPI config file, which I did upload and it allows both POST and GET requests.

I posted this issue in ESP forums, they couldn’t give me any definite answer as to what could be wrong. Everything looks good from ESP side.

It’s just weird that only GET requests get through. POST request get rejected by ESP. May be there’s link alteration going on.

Any debugging ideas from Django side? I’ve tried quite a few things in ESP debugging, everything looks normal.

If it’s on the public internet, it’s in production.

Afraid I can’t think of anything obvious. If your Django logs don’t show the POST requests then it’s in the layer above.

How do you send POST requests? Via JavaScript? Is it fetch or axios or anything else? Check in Chrome Dev Tools if your request leaves the browser at all.