ENG-9553: prepend frontend_path to RouterData.url and RouterData.page.raw_path#6535
Conversation
…ge.raw_path If a frontend path is configured for the app, the framework must prepend it to the reported path, which only includes the internal route path.
Greptile SummaryThis PR ensures that
Confidence Score: 4/5The change is safe to merge; both call sites are straightforward and the fix is well-covered by a new parameterised integration test. The core logic is correct: Next.js strips basePath from asPath before sending it to the backend, so prepending frontend_path server-side is the right fix. The only observations are minor — get_config() is called twice per request where once would suffice, and the test has a redundant regex assertion that cannot catch anything the exact-value check misses. No files require special attention; both changed files are straightforward. Important Files Changed
Sequence DiagramsequenceDiagram
participant Browser
participant Frontend as Next.js Frontend
participant Backend as Reflex Backend
participant RouterData as RouterData.from_router_data()
Browser->>Frontend: Navigate to /prefix/dynamic/42
Note over Frontend: basePath="/prefix"<br/>router.asPath="/dynamic/42"
Frontend->>Backend: "WebSocket: {asPath: "/dynamic/42", pathname: "/dynamic/[page_id]"}"
Backend->>RouterData: from_router_data(router_data)
RouterData->>RouterData: "raw_path = prepend_frontend_path("/dynamic/42") -> "/prefix/dynamic/42""
RouterData->>RouterData: "url = ReflexURL(host + "/prefix/dynamic/42")"
RouterData-->>Backend: "RouterData(url="https://host/prefix/dynamic/42", page.raw_path="/prefix/dynamic/42")"
Backend-->>Frontend: State delta with updated router
Frontend-->>Browser: "router.url.path = "/prefix/dynamic/42""
|
This is in addition to the {base} assertion which really is only a validation
that the AppHarness itself is giving us the correct link.
If a frontend path is configured for the app, the framework must prepend it to the reported path, which only includes the internal route path.