Skip to content

Adding root_path breaks admin page #538

@mmzeynalli

Description

@mmzeynalli

Checklist

  • The bug is reproducible against the latest release or master.
  • There are no similar issues or pull requests to fix it yet.

Describe the bug

I have multiple endpoints and admin panel. I want my endpoints to be in root path of /api/v1/, but admin to be just /admin/. So, I added app_configs["root_path"] = f"/api/v{settings.APP_VERSION}", and admin panel breaks down.

Steps to reproduce the bug

app_configs: dict[str, Any] = {"title": "Itinerago API"}
app_configs["root_path"] = f"/api/v{settings.APP_VERSION}"

app = FastAPI(**app_configs)
app.include_router(auth_router, prefix="/auth", tags=["Auth"])
app.include_router(core_router, prefix="", tags=["Main Logic"])


admin = Admin(app, engine)

# admin.add_view-s here

Commenting out second line fixes admin, however, it does not give desired output.

Expected behavior

APIs will have /api/v1/ prefix, but, admin will not. Admin will load without a problem.

Actual behavior

Admin breaks down completely:

image

and

image

Links are also broken:
In the first image, when you click one of the models it goes to: /api/v1/admin/model/list

image

Debugging material

No response

Environment

Windows, Python 3.10, Dockerized Fastapi
sqladmin version 0.12.0

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions