Code Monkey home page Code Monkey logo

Comments (7)

pfdgithub avatar pfdgithub commented on May 29, 2024 1

#53

试了一下,发现几个问题:

  1. 对 ws 代理的处理造成 recoverRequest 未被调用
  2. 代理配置了 agent 造成 proxyReq 事件冲突。
  3. 优先使用用户配置的 configure 参数。

from vite-plugin-mock-dev-server.

pfdgithub avatar pfdgithub commented on May 29, 2024

一个可能得解决方案是,将 body 延迟提取。从直接赋值改为 get 访问器,使用时才提取。但这样需要将 body 的异步提取,改为同步提取,可能还要更换第三方解析库。

也可以简单粗暴一点,允许关闭内置的 body 提取逻辑,这样就不用改动太多了。
https://github.com/pengzhanbo/vite-plugin-mock-dev-server/blob/main/src/baseMiddleware.ts#L74

image


临时修改 node_modules 下文件使用
image

from vite-plugin-mock-dev-server.

pengzhanbo avatar pengzhanbo commented on May 29, 2024

由于请求流被消费导致的代理转发失败。
这个修复倒是不需要调整 parseBody。 在请求进入阶段,备份请求流,然后在 代理请求发出前,重新写入备份的数据流即可。

vite 内部有暴露 获取 http-proxy 的实例,可以拿到实例然后进行处理。

from vite-plugin-mock-dev-server.

pfdgithub avatar pfdgithub commented on May 29, 2024

加了两条建议,你看看要不要调整下,然后发个 beta 版本我试试?

from vite-plugin-mock-dev-server.

pengzhanbo avatar pengzhanbo commented on May 29, 2024

已调整相关代码并进行了本地验证,并发布了一个 v1.3.4-beta.0 的版本, 可通过 pnpm add -D vite-plugin-mock-dev-server@next 进行安装。

from vite-plugin-mock-dev-server.

pengzhanbo avatar pengzhanbo commented on May 29, 2024

发布了一个 v1.3.4-beta.1 的版本,用于继续进行验证

from vite-plugin-mock-dev-server.

pfdgithub avatar pfdgithub commented on May 29, 2024

验证通过

from vite-plugin-mock-dev-server.

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.