pdm install
These are equivalent (given the main.py code)
UVICORN_ROOT_PATH=/api/ pdm run uvicorn main:app
FASTAPI_ROOT_PATH=/api/ pdm run uvicorn main:app
pdm run uvicorn main:app --root-path /api
Expected response from all 3 variants:
$ curl http://127.0.0.1:8000/
{"message":"Hello World","root_path":"/api/"}
AWS ALB doesn't do url path rewriting, so when we have a Listener Rule that forward all requests that match an /api
prefix to our FastAPI backend, it will pass back the whole url, including the prefix. So what we really need to work is this:
$ curl http://127.0.0.1:8000/api/
{"message":"Hello World","root_path":"/api/"}
without changing the whole application.
also expected (probably)