uvicorn icon indicating copy to clipboard operation
uvicorn copied to clipboard

Fix access logs for mounted apps not containing root path

Open levrik opened this issue 3 years ago • 2 comments

I've started to use get_path_with_query_string for websockets logging as well to have a single place responsible for creating the path for logging. I don't know why this method wasn't used before so in case I'm missing something here, please let me know.

Fixes #1384

levrik avatar Feb 22 '22 11:02 levrik

I was looking into the linked issue https://github.com/encode/starlette/issues/1336 and since FastAPI uses Starlette under the hood, this is probably where the issue originates from. From my point of view the fix done in #1290 is legit but causes some issues due to https://github.com/encode/starlette/issues/1336. The change to using raw_path might not be correct as well as path should be completed by spec but is broken in combination with Starlette. Maybe a revert to combining root_path and path should be done until Starlette is fixed? I'm feeling unsure about the change to raw_path.

levrik avatar Feb 22 '22 11:02 levrik

@levrik Yes I think you're right and also changing back to root_path + path would make more sense as according the ASGI the raw_path can be optional.

The change to use get_path_with_query_string for websocket looks reasonable though.

aminalaee avatar Feb 22 '22 11:02 aminalaee