get_route_path() not handling 'app_root_path' #2928
Unanswered
karmaBonfire
asked this question in
Potential Issue
Replies: 1 comment
-
8000
Here's my traefik configuration if you wish to debug this - create these files near traefik executable and run traefik.toml [entryPoints]
[entryPoints.http]
address = ":9999"
[providers]
[providers.file]
filename = "routes.toml" routes.toml [http]
[http.middlewares]
[http.middlewares.test-replacepathregex.replacePathRegex]
regex = "^/foo(.*)"
replacement = "$1"
[http.routers]
[http.routers.app-http]
entryPoints = ["http"]
service = "app"
rule = "PathPrefix(`/foo`)"
middlewares = ["test-replacepathregex"]
[http.services]
[http.services.app]
[http.services.app.loadBalancer]
[[http.services.app.loadBalancer.servers]]
url = "http://127.0.0.1:8000" |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Consider this setup:
localhost:9999
that strips prefix/foo
from the path, e. g./foo/bar/login
->/bar/login
localhost:8000
:Querying a reverse proxy (traefik in my case), I expected
GET /foo/bar/login
to produce'hello, world'
response. However, this app returns 404 Not Found. I managed to identify the issue and made a dirty fix, however, I'm not sure if this is a bug or a user error.At some point during routing,

score['root_path']
contains ascope['app_root_path']
, whilescope['path']
does not (since it was replaced by reverse proxy), as shown below (reproduce by setting a breakpoint on linematch, child_scope = route.matches(scope)
inRouter.app()
)My dirty fix adds code that handles this case to
starlette._utils.get_route_path()
:Beta Was this translation helpful? Give feedback.
All reactions