fix: keep client router.replace relative for sub-path deployments - #630
Open
c-with wants to merge 1 commit into
Open
fix: keep client router.replace relative for sub-path deployments#630c-with wants to merge 1 commit into
c-with wants to merge 1 commit into
Conversation
router.replace("/") in handleCwdChange/handleNewSession/branch-switch pushes the browser to the origin root, breaking deployments behind a path-prefix reverse proxy. Use window.location.pathname so the replace clears the session query param without leaving the mount prefix.
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.
What does this PR do?
Three
router.replace("/")calls inAppShell.tsx(handleCwdChange,handleNewSession, branch-switch cleanup) push the browser to the origin root, discarding the mount prefix on deployments served behind a path-prefix reverse proxy (e.g.example.com/pi/). The user lands on a 404/blank root page after switching project, creating a session, or switching branch.Fix: replace
"/"withwindow.location.pathnameso the replace keeps the current mount prefix while still clearing the?session=query param. The original intent (drop the session query) is preserved — only the destination changes.Related Issue
No existing issue found for this. (Happy to file one first if preferred — sub-path deployments were discussed in #370 / #50 but those were about basePath support, which stays out of scope here.)
Changes Made
components/AppShell.tsx— 3 call sites,"/"→typeof window !== "undefined" ? window.location.pathname : "/".Verification
Deployed behind an Nginx reverse proxy at a
/pi/prefix (proxy strips the prefix, no basePath — same shape as #370 discussion): before the fix, project switch / new session / branch switch all navigate the browser to the origin root; after, they stay on the mounted prefix and only the?session=param clears. Also rancomponents/AppShell*vitest suites (pass) andtsc --noEmit(clean).中文摘要:子路径反代部署下
router.replace("/")会把浏览器顶到域名根路径,切换项目/新建会话/切换分支后直接 404。改为window.location.pathname保留挂载前缀,仅清除 session 查询参数——原语义不变,只改目的地。