New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding root_path breaks admin page #538
Comments
Hey,
Generally I think this makes sense since you want to handle multiple API versionings in your app, running at the same time so setting the version on the whole app might not be a good idea. |
Default base_url suits me, however, whenever set any root_path, admin gets messy like I showed in screenshots. You second point would work, but, it is hassle to add |
Anyway if you want to do that you can just modify admin.app which is just another FastAPI app so you can do any config you want. |
How? Just adding root_path breaks admin panel. Is it expected? |
I haven't tested this before, doesn't setting this work?
|
Just checked, no it does not work. Change the line to: |
@mmzeynalli have you solved this problem? |
To be honest no, unfortunately, have been super busy for the last couple of months. |
A workaround I found is to use a middleware: @app.middleware("http")
async def fix_admin_root_path(request, call_next):
if request.url.path.startswith("/admin/"):
request.scope["path"] = app.root_path + request.url.path
return await call_next(request) |
Checklist
master
.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 addedapp_configs["root_path"] = f"/api/v{settings.APP_VERSION}"
, and admin panel breaks down.Steps to reproduce the bug
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:
and
Links are also broken:
In the first image, when you click one of the models it goes to: /api/v1/admin/model/list
Debugging material
No response
Environment
Windows, Python 3.10, Dockerized Fastapi
sqladmin version 0.12.0
Additional context
No response
The text was updated successfully, but these errors were encountered: