Repository navigation
Stop stripping frontend_path twice when matching routes - #7153
FarhanAliRaza merged 2 commits into
Conversation
The router stripped frontend_path from every path, but the event handler passes the pathname the frontend sends, which is already relative to frontend_path. With frontend_path="/app", /apple resolved to 404 and /app to the index page. Match relative paths in the router and strip frontend_path as a whole segment only in get_load_events, whose path is the browser URL.
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
Merging this PR will not alter performance
Comparing Footnotes
|
A browser URL that does not start with frontend_path is not a page of the app. Keep resolving it to the 404 load events instead of matching it as a relative route.
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Tip: cubic used a learning from your PR history. Let your coding agent read cubic learnings directly with the cubic MCP.
Re-trigger cubic
reflex/utils/exec.py: kept main's threading import alongside the PR's Callable import; dropped the PR's _match_with_frontend_path wrapper because main (reflex-dev#7153) made get_router match frontend_path-relative paths, which the mount already passes tests/units/test_app.py: kept the PR's test_page_routes and main's 404 metadata tests tests/units/utils/test_exec.py: kept the PR's routes-manifest/frontend-mount tests and main's granian tests Claude-Session: https://claude.ai/code/session_01VDzz2un9mtjmCY24zSGmca
closes #7090
What
get_routerstrippedfrontend_pathfrom every path it matched, but its two callers pass different kinds of paths:app.pymatchesrouter_data["pathname"], which the frontend sends relative tofrontend_path(see the comment instate.js). Withfrontend_path="/app",/applebecameleand resolved to 404, and/appbecame/and resolved to the index page.OnLoadInternalState.on_load_internalpassesself.router.url.path, which is the browser URL and does includefrontend_path. This is why the strip was added to the matcher in fix various issues with frontend_path #5698.The router now always matches paths relative to
frontend_path, andApp.get_load_eventsstripsfrontend_pathfrom the URL path itself. It strips it only as a whole path segment, so/app/applestill maps toapple, and a URL outsidefrontend_pathsuch as/applestill gets the 404 load events. The matcher cache is now keyed on the path alone.Tests
Added to
tests/units/test_route.py:test_get_router_ignores_frontend_path: withfrontend_path="/app",/apple,/appand/matchapple,appandindex. On currentmainthe first two fail.test_get_load_events_strips_frontend_path:/app,/app/,/app/appleand/app/appresolve to the right page's load events, and/applefalls back to 404.tests/units/test_route.py: 43 passed.tests/units: 8466 passed. The 207 failures locally are all undertests/units/reflex_cli/v2/and match what I see onmainwithout this change.Checklist
ruff check,ruff format --checkandpyrightpass on the changed files