✨ Support mounting StaticFiles to sub-routers#13944
Open
YuriiMotov wants to merge 4 commits intofastapi:masterfrom
Open
✨ Support mounting StaticFiles to sub-routers#13944YuriiMotov wants to merge 4 commits intofastapi:masterfrom
StaticFiles to sub-routers#13944YuriiMotov wants to merge 4 commits intofastapi:masterfrom
Conversation
|
Having bumped on this silent bug today I think it is a pity that this PR has been sitting here for so long! Anything we can do to push this through? |
10b5cb1 to
c6987ce
Compare
APIRouter.mount() methodStaticFiles to sub-routers
Member
Author
|
Updated PR to support mounting |
kimchikingdom
added a commit
to kimchikingdom/fastapi
that referenced
this pull request
Feb 14, 2026
Per maintainer feedback on fastapi#14924, limit Mount propagation in include_router() to StaticFiles only, matching the approach in fastapi#13944. Non-StaticFiles sub-app mounts are silently ignored (not propagated) to preserve existing behavior, since sub-applications should be mounted directly on the root FastAPI instance. Fixes fastapi#10180
This was referenced Feb 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For now if you try mounting the sub-application to
APIRouterit will be silently ignored.See issue: #10180
This PR makes it working. At the same time mounting other apps to APIRouter will raise
FastAPIErrorwith clear error message