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

域名中包含.js导致子应用渲染失败 #1172

Closed
SepVeneto opened this issue Apr 12, 2024 · 1 comment
Closed

域名中包含.js导致子应用渲染失败 #1172

SepVeneto opened this issue Apr 12, 2024 · 1 comment
Labels
bug Something isn't working solved problem solved

Comments

@SepVeneto
Copy link
Contributor

问题描述

假设子应用部署在地址demo.jstest.com这个域名上,在加载的时候会由于能匹配到.js,导致给html内容包装成micro的结构

const htmlPromise = htmlUrl.includes('.js')

进而导致将子应用的访问地址作为src进行代理,最终渲染的内容就变成

;(function(proxyWindow){with(proxyWindow.__MICRO_APP_WINDOW__){(function(window,self,globalThis,document,Document,Array,Object,String,Boolean,Math,Number,Symbol,Date,Function,Proxy,WeakMap,WeakSet,Set,Map,Reflect,Element,Node,RegExp,Error,TypeError,JSON,isNaN,parseFloat,parseInt,performance,console,decodeURI,encodeURI,decodeURIComponent,encodeURIComponent,navigator,undefined,location,history){
    ;<!doctype html><html>...</html>
}).call(...)

结果就是在控制台上抛出报错

/:1 
 Uncaught SyntaxError: Unexpected token '<'

复现步骤

  1. 随便起一个项目,然后修改本地hosts,加一行192.168.1.9 demo.jstest.com
  2. 主应用的url改为192.168.1.9:8080,能正常渲染子应用
  3. 主应用的url改为demo.jstest.com,控制台报错

上传截图

image

复现仓库

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

环境信息

  • micro-app版本:1.0.0-rc.4
  • 主应用前端框架&版本:vue 3.2.13
  • 子应用前端框架&版本:vue 3.3.4
  • 构建工具&版本:webpack 5.74.0
@SepVeneto SepVeneto changed the title 域名中包含js导致子应用渲染失败 域名中包含.js导致子应用渲染失败 Apr 12, 2024
@bailicangdu bailicangdu added the bug Something isn't working label Apr 15, 2024
@bailicangdu
Copy link
Member

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

@bailicangdu bailicangdu added the solved problem solved label 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