diff --git a/responder/routes.py b/responder/routes.py index 954e858..13db9f6 100644 --- a/responder/routes.py +++ b/responder/routes.py @@ -457,7 +457,7 @@ class Router: # Call into a submounted app, if one exists. for path_prefix, app in self.apps.items(): if path.startswith(path_prefix): - scope["path"] = path[len(path_prefix) :] + scope["path"] = path[len(path_prefix) :] or "/" scope["root_path"] = root_path + path_prefix try: await app(scope, receive, send) diff --git a/tests/test_responder.py b/tests/test_responder.py index e4ef3f8..b2f9375 100644 --- a/tests/test_responder.py +++ b/tests/test_responder.py @@ -546,14 +546,17 @@ def test_documentation(needs_openapi): assert "html" in r.text -def test_mount_wsgi_app(api, flask): +def test_mount_wsgi_app(flask): + # Use localhost so Werkzeug's trusted-host check accepts the request. + api = responder.API(allowed_hosts=["localhost"]) + @api.route("/") def hello(req, resp): resp.text = "hello" api.mount("/flask", flask) - r = api.requests.get("http://;/flask") + r = api.requests.get("http://localhost/flask") assert r.status_code < 300