Skip to content

fix(frontend): prefix raw-anchor and native navigations under subpath deployments - #4559

Merged
xuyaqist merged 2 commits into
developfrom
fix/subpath-raw-anchor-navigations
Dec 4, 2026
Merged

xuyaqist merged 2 commits into
developfrom
fix/subpath-raw-anchor-navigations

Conversation

@jeffwu-1999

@jeffwu-1999 jeffwu-1999 commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

问题

#4558 镜像问题:裸锚点/原生跳转漏加前缀。antd Button href、裸 <a>、window.location 不经过 Next router,框架不会自动加 basePath,必须手动 withBasePath。

现网表现:智能体发布页点"API Key: 点击获取"跳到根路径 /zh/users → 404/被踢回首页。

修复(4 处,全前端扫描确认无遗漏)

  • 发布页"体验"按钮:antd href 改 window.location.assign(shareUrl)(shareUrl 已带前缀,语义明确)
  • API Key 链接两处(发布页 + 使用指南弹窗):裸 <a> 补 withBasePath
  • oauth 完成页"返回首页"按钮:补 withBasePath
  • 注销账号后跳首页:window.location.href 补 withBasePath

验证

20261204153259_rec_
  • agentUsageGuide 相关 15 例测试全过
  • 本地 /nexent 子路径镜像实测:API Key 链接正常跳 /nexent/zh/users

后续

需要做统一导航封装(重一点),防止霰弹式修改:收敛一个 navigate()/ 出口,内部按目标类型(router/原生/外部)自动决定加不加前缀,业务代码不再直接接触 withBasePath。改动面大,适合后续重构做。

… deployments

antd Button href and plain <a> tags render raw anchors that bypass the
Next.js router, so app-internal paths need withBasePath explicitly:
- agent publication preview button now navigates via location.assign
  (shareUrl already carries the prefix; antd href would double it)
- API Key links (publication page + usage guide modal) get withBasePath
- oauth complete back-home button gets withBasePath
- account deletion redirect gets withBasePath
@xuyaqist
xuyaqist merged commit b1c3e45 into develop Dec 4, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants