Code Monkey home page Code Monkey logo

Comments (1)

yiludege avatar yiludege commented on May 22, 2024

这是一个奇怪的问题,分情况讨论吧

1、子应用如果发起的api是绝对地址:“http:xxxx.com/api/xxxx”,那么不管是子应用单独运行还是内嵌在主应用都是这个绝对地址

2、子应用如果发起的api是相对地址:“/api/xxxx”,那么子应用单独运行请求域名是子应用的,内嵌在无界微前端中,host 还是子应用的(子应用运行在 iframe 内,无界在 iframe 内设置了 base 标签来修正相对地址)

如果是情况 2 ,又想子应用内嵌在无界微前端中请求域名是主应用的,那么可以这样做:

a、子应用的 api 请求是 fetch ,可以自定义子应用的 fetch,强制修改 url = host 主应用 + url

b、子应用的 api 请求是 xhr ,那就只能修改子应用的代码,将 url = window.POWERED_BY_WUJIE ? host 主应用 + url : url 这样可以走主应用的域名

from wujie.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.