fix: move profile_router registration before frontend catch-all route (#563)#584
Open
ionfwsrijan wants to merge 11 commits into
Open
fix: move profile_router registration before frontend catch-all route (#563)#584ionfwsrijan wants to merge 11 commits into
ionfwsrijan wants to merge 11 commits into
Conversation
… to fix shadowed endpoints (param20h#563)
68d97f6 to
9aabf64
Compare
…parser) to account for module-level import
Contributor
Author
|
@param20h Please review this |
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.
Description
Route registration order in
backend/app/main.py:/api/v1(lines ~247–252)/{full_path:path}(line ~316)app.include_router(profile_router)(was at line ~355)FastAPI/Starlette matches routes in registration order. The route
/{full_path:path}matches any URL path for GET/HEAD requests. Sinceprofile_routerwas registered after it, all profile endpoints (GET /profile,PUT /profile,POST /profile/avatar) were never reached — the catch-all returned frontend SPA HTML instead.The condition
if os.path.exists(FRONTEND_BUILD_DIR):meant this bug only existed in production/Docker. In development with no frontend build, the catch-all was not registered and profile routes worked fine — creating a dev/prod inconsistency.Changes
backend/app/main.pyapp.include_router(profile_router)from after the frontend catch-all (line 355) to join the other API route registrations (line 253), so profile endpoints are registered before the catch-all and are reachable in production/Docker.Impact
Closes #563