I’m trying to deploy a FastAPI project using docker. I have a very simple route like this:
router = APIRouter()
@router.get("/")
def get_index():
return {"status": "ok"}
On my fly.toml, I have this to start the web process:
[processes]
web = "gunicorn -b :8080 -w 4 -k uvicorn.workers.UvicornWorker app.main:app"
The problem is that I keep getting 307 Temporary Redirect
responses no matter which path I try to request:
> curl -vvv https://<my-app>.fly.dev/
< HTTP/2 307
< location: https://<my-app>.fly.dev/
If I open the URL in the browser, it just ends up in a 307 loop without ever working.
I tried numerous config changes:
- Using uvicorn instead of gunicorn (
uvicorn app.main:app --host 0.0.0.0 --port 8080
) - Using only http1.1 (
curl -vvv --http1.1 ...
) - Specific FastAPI code changes
It seems like it might be something related to the way Fly proxies the requests to the FastAPI, but I can’t figure out what it is.
Help appreciated!