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

子应用url会在pathname后追加一个‘/’, 导致后端路由匹配不上 #1147

Closed
jinxiaochuan opened this issue Mar 29, 2024 · 2 comments
Labels
bug Something isn't working solved problem solved

Comments

@jinxiaochuan
Copy link

问题描述

问题的具体描述
子应用url会在pathname后追加一个‘/’, 导致后端路由匹配不上

复现步骤

假设子应用地址为 https://www.example.com/pathname

  1. 查看控制台中实际加载子应用的fetch请求是: https://www.example.com/pathname/
  2. 查看源码中的formatAppURL方法
export function formatAppURL (url: string | null, appName: string | null = null): string {
  if (!isString(url) || !url) return ''

  try {
    const { origin, pathname, search } = createURL(addProtocol(url), (window.rawWindow || window).location.href)
    // If it ends with .html/.node/.php/.net/.etc, don’t need to add /
    if (/\.(\w+)$/.test(pathname)) {
      return `${origin}${pathname}${search}`
    }
    const fullPath = `${origin}${pathname}/`.replace(/\/\/$/, '/')
    return /^https?:\/\//.test(fullPath) ? `${fullPath}${search}` : ''
  } catch (e) {
    logError(e, appName)
    return ''
  }
}
  1. 希望可以移除这个逻辑或者增加配置项允许不追加‘/’

上传截图

请上传代码截图、控制台、终端等截图以帮助我们了解您的问题。

复现仓库

请提供一个精简的代码仓库,然后上传到自己的 github,以帮助我们复现您的问题。

环境信息

  • micro-app版本:1.0.0-rc.2
  • 主应用前端框架&版本:react 18.2.0
  • 子应用前端框架&版本:react 18.2.0
  • 构建工具&版本:vite 4.5.0
@bailicangdu bailicangdu added the Working on it Working on this issue label Mar 29, 2024
@bailicangdu
Copy link
Member

好的,感谢反馈

@bailicangdu
Copy link
Member

已修复,更新到1.0.0-rc.5版本即可

@bailicangdu bailicangdu added bug Something isn't working solved problem solved and removed Working on it Working on this issue labels Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working solved problem solved
Projects
None yet
Development

No branches or pull requests

2 participants