We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
You can continue the conversation there. Go to discussion →
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Originally posted by robbielaw February 8, 2024
When running starlette/fastapi behing a proxy we got some errors when calling the app directly.
when calling curl http://127.0.0.1:8000/products/, we get: root_path: /product scope['path']: /products route_path: s (after apply the regex - https://github.com/encode/starlette/blob/master/starlette/_utils.py#L96) because the the root_path to be removed if calling directly the app is "product" and endpoint path is /products
Example Scenario: libs:
starlette==0.37.2 uvicorn==0.29.0
gist: https://gist.github.com/gabriel-f-santos/df75213fe6860e369a1e096611a767e5 run: uvicorn main:app --root-path /product
Code causing the error: https://github.com/encode/starlette/blob/master/starlette/_utils.py#L96
def get_route_path(scope: Scope) -> str: root_path = scope.get("root_path", "") route_path = re.sub(r"^" + root_path, "", scope["path"]) return route_path
Fix suggestion:
def get_route_path(scope: Scope) -> str: root_path = scope.get("root_path", "") route_path = re.sub(r"^" + root_path + r"(?=/|$)", "", scope["path"]) return route_path
[!IMPORTANT] We're using Polar.sh so you can upvote and help fund this issue. We receive the funding once the issue is completed & confirmed by you. Thank you in advance for helping prioritize & fund our backlog.
[!IMPORTANT]
The text was updated successfully, but these errors were encountered:
root_path
get_route_path
No branches or pull requests
Discussed in #2495
Originally posted by robbielaw February 8, 2024
When running starlette/fastapi behing a proxy we got some errors when calling the app directly.
when calling curl http://127.0.0.1:8000/products/, we get:
root_path: /product
scope['path']: /products
route_path: s (after apply the regex - https://github.com/encode/starlette/blob/master/starlette/_utils.py#L96)
because the the root_path to be removed if calling directly the app is "product" and endpoint path is /products
Example Scenario:
libs:
gist: https://gist.github.com/gabriel-f-santos/df75213fe6860e369a1e096611a767e5
run: uvicorn main:app --root-path /product
Code causing the error:
https://github.com/encode/starlette/blob/master/starlette/_utils.py#L96
Fix suggestion:
The text was updated successfully, but these errors were encountered: