Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] ssr 未处理 base #11233

Open
PeachScript opened this issue Jun 5, 2023 · 4 comments · May be fixed by #12140
Open

[Bug] ssr 未处理 base #11233

PeachScript opened this issue Jun 5, 2023 · 4 comments · May be fixed by #12140
Assignees

Comments

@PeachScript
Copy link
Member

What happens?

开启 ssr 后输出产物中的前端路由链接 href 没有正确的 base 前缀

How To Reproduce

Steps to reproduce the behavior:

  1. Umi 脚手架开启 ssr + exportStatic 配置项
  2. 配置 basepublicPath 均为 /a/
  3. 配置 outputPathdist/a
  4. 执行构建
  5. 托管 dist 目录并通过浏览器访问 /a 路径下的应用
  6. 检查源代码中前端路由连接的 href 值会发现不是 /a/ 前缀

Expected behavior

前端路由连接的 href 值为 /a/ 前缀

关键代码位置:https://github.com/umijs/umi/blob/master/packages/renderer-react/src/server.tsx#L17

Context

  • Umi Version: 4.x
  • Node Version: 16.x
  • Platform: macOS
@Wxh16144
Copy link
Member

6. 检查源代码中前端路由连接的 href 值会发现不是 /a/ 前缀

确实不是 /a/ 前缀, 但是启动 dist server 后点击 href 还是正常跳转了的, 这是一个 bug 吗?

@PeachScript
Copy link
Member Author

是 bug,点击能正确跳转应该是因为 react-router 劫持了超链接默认行为,但对于搜索引擎(SEO)或浏览器(新窗口打开)来说,链接就是错误的了

@Wxh16144 Wxh16144 self-assigned this Jul 27, 2023
@Wxh16144
Copy link
Member

好, 交给我试试

@xlei1123
Copy link

xlei1123 commented Aug 6, 2023

我现在用的3.5也遇到了这个问题,添加base后,ssr渲染 无法成功,并且控制台总是报did not match错误

@jaykou25 jaykou25 linked a pull request Feb 25, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants