Hi,
I have a Cloud Run instance running a FastAPI app. This instance is behind a GCP Load Balancer.
I have an endpoint which looks like /status.
When querying /status/ on Chrome: everything works fine, I get a 307 redirect from FastAPI to be redirected to /status (since this is how the endpoint is defined in my app, without a trailing slash)
These are my Cloud Run Logs
GET307 Chrome 122 https://my-api.com/status/
INFO: "GET /status/ HTTP/1.1" 307 Temporary Redirect
GET200 Chrome 122 https://my-api.com/status
INFO: "GET /status HTTP/1.1" 200 OK
When querying /status/ outside of Chrome (Postman/Python/Curl/and probably many others): I also get a redirect, but I get the following error when the redirect happens ConnectionResetError(54, 'Connection reset by peer') and read ECONNRESET on Postman.
And here are my logs for this:
GET307 PostmanRuntime/7.36.3 https://my-api.com/status/
INFO: "GET /status/ HTTP/1.1" 307 Temporary Redirect
I don't get anything else after this Redirect (Connection reset on my client).
Also important to note that this only happens when I query this endpoint through the GCP Load Balancer. When querying the same endpoint directly through the Cloud Run URL, I don't get any errors.
Thank you for your help.
New: it started working after I added a redirect rule to the load balancer to redirect HTTP to HTTPS. Not sure if its related to my issue or if it was an issue on Google's side but now its working. Very strange..
Edit: It was related, FastAPI was responding with an HTTP redirect link making my application crash on the client (for some reason Google Chrome natively redirects to HTTPS I guess). This gives more details: https://stackoverflow.com/questions/63511413/fastapi-redirection-for-trailing-slash-returns-non-ssl-...