Skip to content

Commit 3ab2d66

Browse files
committed
Prefer root_path over base_path
1 parent 72e5bb4 commit 3ab2d66

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/stac_auth_proxy/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,13 @@ async def lifespan(app: FastAPI):
138138
app.add_middleware(
139139
ProcessLinksMiddleware,
140140
upstream_url=str(settings.upstream_url),
141-
base_path=settings.root_path,
141+
root_path=settings.root_path,
142142
)
143143

144144
if settings.root_path:
145145
app.add_middleware(
146146
RemoveRootPathMiddleware,
147-
base_path=settings.root_path,
147+
root_path=settings.root_path,
148148
)
149149

150150
if settings.enable_compression:

src/stac_auth_proxy/middleware/RemoveRootPathMiddleware.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Middleware to remove BASE_PATH from incoming requests and update links in responses."""
1+
"""Middleware to remove ROOT_PATH from incoming requests and update links in responses."""
22

33
import logging
44
from dataclasses import dataclass
@@ -15,26 +15,26 @@ class RemoveRootPathMiddleware:
1515
server.
1616
1717
IMPORTANT: This middleware must be placed early in the middleware chain (ie late in
18-
the order of declaration) so that it trims the base_path from the request path before
18+
the order of declaration) so that it trims the root_path from the request path before
1919
any middleware that may need to use the request path (e.g. EnforceAuthMiddleware).
2020
"""
2121

2222
app: ASGIApp
23-
base_path: str
23+
root_path: str
2424
transform_links: bool = True
2525

2626
json_content_type_expr: str = r"application/(geo\+)?json"
2727

2828
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
29-
"""Remove BASE_PATH from the request path if it exists."""
29+
"""Remove ROOT_PATH from the request path if it exists."""
3030
if scope["type"] != "http":
3131
return await self.app(scope, receive, send)
3232

3333
path = scope["path"]
3434

35-
# Remove base_path if it exists at the start of the path
36-
if path.startswith(self.base_path):
35+
# Remove root_path if it exists at the start of the path
36+
if path.startswith(self.root_path):
3737
scope["raw_path"] = scope["path"].encode()
38-
scope["path"] = path[len(self.base_path) :] or "/"
38+
scope["path"] = path[len(self.root_path) :] or "/"
3939

4040
return await self.app(scope, receive, send)

0 commit comments

Comments
 (0)