I found a solution by referring to this GitHub issue: https://github.com/encode/uvicorn/issues/369.
To be more specific, I changed the way I was starting my FastAPI web app. Previously, I used:
fastapi run --workers 4 app/main.py
I switched to using directly Uvicorn with the following command:
uvicorn your_app:app --host 0.0.0.0 --port 8000 --proxy-headers --forwarded-allow-ips "*"