Skip to content

Commit

Permalink
fix: incorrect path passed to asgi app (#28)
Browse files Browse the repository at this point in the history
Fix issue introduced in #27 that caused the admin app to receive paths with a double-forward slash, e.g., `/admin//something`.

 Adds logic to reset the `scope['path']` value on exit of the wrapped asgi app handler.
  • Loading branch information
peterschutt authored Aug 14, 2024
1 parent 556d3c2 commit 597603f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/sqladmin_litestar_plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,14 @@ async def wrapped_app(scope: Scope, receive: Receive, send: Send) -> None:
by appending admin base_url stripped by the mounted route handler
"""
app = scope["app"]
scope["path"] = f"{mount_path}/{scope['path']}"
path = scope["path"]
scope["path"] = f"{mount_path}{path}"
try:
await self.app(scope, receive, send) # type: ignore[arg-type]
except Exception:
logger.exception("Error raised from SQLAdmin app")
scope["app"] = app
scope["path"] = path

app_config.route_handlers.append(wrapped_app)
return app_config
Expand Down

0 comments on commit 597603f

Please sign in to comment.