You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an issue with what's claimed the following PR: #2400. I do not see where you can read "The ASGI spec specifies that path should include the full root_path, which is different from the equivalent in WSGI, that strips the root path equivalent"
So from what I understand, the ASGI spec says that root_path should behave the same as SCRIPT_NAME does for WSGI.
I'm testing with an app that registers a single route at /foo. When I use SCRIPT_NAME=/my-prefix with gunicorn + flask, I get a 200 for curl localhost:8000/my-prefix/foo but not for curl localhost:8000/foo, but when using --root-path with uvicorn + fastAPI it gives 200 for /foo and 404 for /my-prefix/foo. Worse, if I pass the arg through FastAPI (e.g. FastAPI(root_path="/my-prefix")), it gives me a 200 for both /foo and /my-prefix/foo.
What is the expected behavior exactly? As far as I understand it should work the same as with gunicorn, unless I was looking at the wrong version of the ASGI spec, or gunicorn doesn't respect the WSGI spec.
What I feel like is that the root_path in fastAPI/uvicorn was thought to be used only behind proxies that strip the prefix, but that contradicts the ASGI spec, and I believe it's not useful because the proxy that strips the prefix should also be responsible for reformatting redirects to add the prefix back.
By the way, even before the changes in that PR the behavior was the same (e.g. serving on /foo and not /my-prefix/foo - not both though, I think the FastAPI(root_path=...) behavior is actually a bug that was introduced with the root_path changes in FastAPI, might create a separate ticket for this if needed).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have an issue with what's claimed the following PR: #2400. I do not see where you can read "The ASGI spec specifies that path should include the full root_path, which is different from the equivalent in WSGI, that strips the root path equivalent"
When looking at the ASGI spec ( https://asgi.readthedocs.io/en/latest/specs/www.html#http-connection-scope ), what I read is: "The root path this application is mounted at; same as SCRIPT_NAME in WSGI". And the description of the
path
variable makes no mention ofroot_path
.So from what I understand, the ASGI spec says that
root_path
should behave the same asSCRIPT_NAME
does for WSGI.I'm testing with an app that registers a single route at
/foo
. When I useSCRIPT_NAME=/my-prefix
with gunicorn + flask, I get a 200 forcurl localhost:8000/my-prefix/foo
but not forcurl localhost:8000/foo
, but when using--root-path
with uvicorn + fastAPI it gives 200 for/foo
and 404 for/my-prefix/foo
. Worse, if I pass the arg through FastAPI (e.g.FastAPI(root_path="/my-prefix")
), it gives me a 200 for both/foo
and/my-prefix/foo
.What is the expected behavior exactly? As far as I understand it should work the same as with gunicorn, unless I was looking at the wrong version of the ASGI spec, or gunicorn doesn't respect the WSGI spec.
What I feel like is that the
root_path
in fastAPI/uvicorn was thought to be used only behind proxies that strip the prefix, but that contradicts the ASGI spec, and I believe it's not useful because the proxy that strips the prefix should also be responsible for reformatting redirects to add the prefix back.By the way, even before the changes in that PR the behavior was the same (e.g. serving on
/foo
and not/my-prefix/foo
- not both though, I think theFastAPI(root_path=...)
behavior is actually a bug that was introduced with theroot_path
changes in FastAPI, might create a separate ticket for this if needed).Beta Was this translation helpful? Give feedback.
All reactions