I saw that https://github.com/litestar-org/litestar/issues/2998 was closed but I do think Litestar is affected. At least, maybe I need to do something different to work around it.
Once Uvicorn is upgraded to v0.26 or beyond, the path query type gets the value of --root-path prepended to it. This is new behavior that is breaking some of my Litestar apps if I go past Uvicorn 0.25. I can update my code to accommodate but, since this is new behavior, I wanted to confirm this new behavior is expected.
MCVE:
Uvicorn <0.26:
- uvicorn mcve:app --root-path /test
- curl http://localhost:8000/myPath -> "path: /myPath"
Uvicorn >=0.26:
- uvicorn mcve:app --root-path /test
- curl http://localhost:8000/myPath -> "path: /test/myPath"
from pathlib import Path
from litestar import Litestar
from litestar.handlers import get
@get(path=["/", "/{path:path}"], sync_to_thread=False)
def pathfinder(path: Path | None) -> str:
return f"path: {path}"
app = Litestar(route_handlers=[pathfinder], debug=True)
Cheers!