@cypress/debugging-proxy

中文文档
2.0.1发布于 2019/05/07MITCommonJS近 30 天下载 19.4万

节点- 调试- 代理qq

中文使用文档
文档目录8 节
  1. 安装
  2. 用法( 作为独立的服务器)
  3. 在端口1337启动代理
  4. 使用自定义端口
  5. 显示所有请求的日志
  6. 代理访问需要 HTTP 基本 Auth
  7. 使用自定义密钥和证书复制 HTTPS 代理
  8. 用法(作为一个模块,在测试中)

节点调试- 代理

NPM

一个简单的 HTTP 代理, 代表 HTTP 和 HTTP 透明地请求 。 用于调试您的应用程序与代理正确工作 .

安装

npm i -g @cypress/debugging-proxy

## or, if you prefer yarn
yarn global add @cypress/debugging-proxy

用法( 作为独立的服务器)

在端口1337启动代理

debugging-proxy

使用自定义端口

PORT=1234 debugging-proxy

显示所有请求的日志

DEBUG=proxy debugging-proxy

代理访问需要 HTTP 基本 Auth

PROXY_USER=some-username PROXY_PASS=some-password debugging-proxy

使用自定义密钥和证书复制 HTTPS 代理

HTTPS_KEY=/path/to/key.key HTTPS_CERT=/path/to/cert.pem debugging-proxy

用法(作为一个模块,在测试中)

const debugProxy = require('@cypress/debugging-proxy')

// create an instance
const proxy = new debugProxy({
    auth: { // if `auth` is set, HTTP basic authentication to the proxy will be required using these credentials
        username: 'foo',
        password: 'bar'
    },
    keepRequests: false, // if `keepRequests` is set, the proxy will store a log of requests that can be retrieved using `proxy.getRequests()`
    https: { // if https is set, https.createServer will be called with this key and cert to launch the server
        key: fs.readFileSync('my-key.pem'),
        cert: fs.readFileSync('my-cert.pem')
    }
})

// using your stubbing/spying library of choice...
spy(proxy.proxyRequestToUrl)
spy(proxy.proxySslConnectionToDomain)

// start an httpproxy on localhost:3000
proxy.start(3000).then(() => {
    // make some requests using the proxy at localhost:3000, then...
    expect(proxy.proxyRequestToUrl).to.be.calledWith('http://google.com')
    expect(proxy.proxySslConnectionToDomain).to.be.calledWith('google.com')

    expect(proxy.getRequests().find(incomingMessage => incomingMessage.ssl === false)).to.exist

    // clean up
    proxy.stop().then(() => {
        console.log('All done!')
    })
})

版本与发布记录

@cypress/debugging-proxy 共发布 3 个版本,首次发布于 2019/04/02;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.0.1latest2019/05/077 年前
2.0.02019/05/067 年前
1.6.02019/04/027 年前

关于 @cypress/debugging-proxy 的常见问题

@cypress/debugging-proxy 是什么?

节点- 调试- 代理qq

如何安装 @cypress/debugging-proxy?

在项目目录运行 npm install @cypress/debugging-proxy,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 debugging-proxy,可以用 npx debugging-proxy 直接运行。

@cypress/debugging-proxy 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/cypress__debugging-proxy 是否存在。

@cypress/debugging-proxy 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@cypress/debugging-proxy 可以商用吗?

@cypress/debugging-proxy 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@cypress/debugging-proxy 的下载量有多少?

根据 npm 官方下载统计,@cypress/debugging-proxy 在 2026/10/11 – 2026/11/09 这 30 天内被下载 193,588 次,日均约 6,453 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cypress/debugging-proxy 还在维护吗?

最新版本 2.0.1 发布于 2019/05/07(7 年前);至今共发布 3 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/04/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。