Skip to content

Commit 7050bf9

Browse files
committed
fix: root redirect now uses settings.app_root_path and includes trailing slash to avoid 307 redirect
Signed-off-by: ESnark <31977180+ESnark@users.noreply.github.com>
1 parent d0edab6 commit 7050bf9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

mcpgateway/main.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5150,7 +5150,7 @@ async def cleanup_import_statuses(max_age_hours: int = 24, user=Depends(get_curr
51505150
@app.get("/")
51515151
async def root_redirect(request: Request):
51525152
"""
5153-
Redirects the root path ("/") to "/admin".
5153+
Redirects the root path ("/") to "/admin/".
51545154
51555155
Logs a debug message before redirecting.
51565156
@@ -5159,14 +5159,14 @@ async def root_redirect(request: Request):
51595159
target URL via :pymeth:`starlette.requests.Request.url_for`).
51605160
51615161
Returns:
5162-
RedirectResponse: Redirects to /admin.
5162+
RedirectResponse: Redirects to /admin/.
51635163
51645164
Raises:
51655165
HTTPException: If there is an error during redirection.
51665166
"""
5167-
logger.debug("Redirecting root path to /admin")
5168-
root_path = request.scope.get("root_path", "")
5169-
return RedirectResponse(f"{root_path}/admin", status_code=303)
5167+
logger.debug("Redirecting root path to /admin/")
5168+
root_path = settings.app_root_path
5169+
return RedirectResponse(f"{root_path}/admin/", status_code=303)
51705170
# return RedirectResponse(request.url_for("admin_home"))
51715171

51725172
else:

0 commit comments

Comments
 (0)