502 bad gateway for post requests

I have a school project in which involves an expess backend. Cors is setup already in the backend with the official cors middleware to communicate with the front end of my project. I have an issue every time i create a post request to my backend hosted on render. I deployed it from a docker container imade.

To test the responses i used swagger

The response to a post request on render

The response to the same request hosted on google cloud platform (the same result as my local server as well)

However all the get requests seem to work on render

Assistance would be much appreciated

Hi, I have the exact same issue. I am try to solve it since hours. Nothing seems to work.

I have a web application.
Flask backend
React frontend
→ So in two folders and an am deploying them together through github GitHub - PaoloOppelt/latest_GPT

I use the .env.production REACT_APP_BACKEND_URL=https://www.leitliniengpt.de/
located in my frontend folder. If i use localhost5000 and use docker locally it all works perfectly fine. Also using get on Postman

/api/status

{
“status”: “API is working”
}

Only the Post requests don’t seem to work not sure why i always get bad request 502 bad gateway? I am new to coding in general and not an expert on any of this so an easy to understand and answer is highly appreciated.

Is the problem with the way I set up my project? Or code I wrote? Feel free to briefly look at my files on Github.

Best regards,
Paolo

If the post requests work when you run your flask locally then its probably not your code. I see you are also using cors so it cant be a cors problem. I think we’ll have to wait until a render official explains to us what the actual problem is. To double check you can also check your network tab in dev tools and your console to see any extra error messages that might occur.

Hi Bradley,

thank.

Here is the output from the network tab (the only thing I understand from the output is that it say bad gateway)

Backend URL from env: (website link)
main.7bda5524.js:2 Backend URL from env: (website link)
main.7bda5524.js:2 Request URL: (website link)//process
main.7bda5524.js:2 Environment variable: (website link)
main.7bda5524.js:2 Sending request to: (website link)//process
//process:1

   Failed to load resource: the server responded with a status of 502 ()

main.7bda5524.js:2 Response status: 502
main.7bda5524.js:2 Error sending the query to the backend: Error: HTTP error! status: 502
at onSubmit (main.7bda5524.js:2:334878)
onSubmit @ main.7bda5524.js:2
manifest.json:1

   Failed to load resource: the server responded with a status of 502 ()

main.589a14be.css:1

   GET  (website) 589a14be.css net::ERR_ABORTED 502 (Bad Gateway)

Hi there,

Responses that are 502 responses will not contain the required CORS headers. This is because a 502 response comes from our Proxy rather than your service. You will need to resolve the issue with your service that caused the 502 response.

When you make the POST request check your service logs for errors. Also, check that your service isn’t going into an Unhealthy status.

Regards,

Keith
Render Support, UTC+10 :australia: