GithubHelp home page GithubHelp logo

jqk6 / bproxy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zobor/bproxy

0.0 1.0 0.0 6.64 MB

Cross Platform Network Proxy Tools

Home Page: https://www.duelpeak.com/pages/bproxy

Shell 0.08% JavaScript 67.28% TypeScript 10.77% CSS 20.33% HTML 0.09% SCSS 1.46%

bproxy's Introduction

bproxy

bproxy 一款代理工具,为前端开发带来乐趣。配置文件是一个 JS 脚本,你可以在里面写 NodeJS 代码。

bproxy 的核心功能

  • 独立配置: 配置文件可以跟着项目走,支持多人跨平台协同开发
  • 抓包:http、https、ws、wss
  • https过滤:自定义需要抓包的 https 白名单
  • 代理webSocket: 本地开发修改代码,自动刷新
  • 修改响应内容:指向本地文件、指向本地目录、指向本地 http 服务、自定义响应头。
  • HTTPS证书:自动安装 https 证书
  • HOST:一个域名可以配置多个 host
  • 弱网模拟:弱网模拟支持自定义延时配置
  • Chrome开发者工具:远程调试

官网

Documents

工具箱

Tools

安装

命令行工具

npm i bproxy -g

升级

npm i bproxy@latest -g

App Support

支持 Windows & MacOS

下载地址:Download App

如何配置

配置文件 bproxy.config.js

module.exports = {
  port: 8888, // 本地代理服务器的端口
  https: true, // 开启所有的https都抓包
  // 代理规则列表
  rules: [
    {
      // url是匹配什么什么请求
      url: 'https?://m.v.qq.com/tvp/',
      // target是配置请求如何响应,返回字符串内容
      target: 'hello world',
    },
  ],
};

其他配置

线上资源代理到本地

把服务端目录代理到本地目录

{
  url: 'https://google.com/static/**',
  target: '/path/to/your/folder'
}

把服务端文件代理到本地文件

{
  url: 'https://google.com/static/a.js',
  target: '/path/to/your/folder/a.js'
}

把服务端 url 代理到 local server

{
  url: 'https://baidu.com/pages/demo',
  target: 'http://127.0.0.1:3000',
}

自定义请求头和响应头

{
  url: 'https://google.com/user',
  responseHeaders: {
    "Access-Control-Allow-Origin": "https://qq.com",
    "Access-Control-Allow-Credentials": "true",
  },
  requestHeaders: {
    "cache-control": "no-store",
  },
}

配 HOST

// 同一个域名下,不同的接口,可以配置不同的host
{
  url: 'https://google.com/api/user',
  target: '127.0.0.1',
}

{
  url: 'https://google.com/api/login',
  target: '192.168.0.1',
}

模拟请求异常

请求 http 状态码502

{
  url: 'https://google.com/user',
  target: 502,
}

弱网

2s 后返回

{
  url: 'https://google.com/user',
  delay: 2000, // 2000ms
}

设置代理

{
  url: 'https://google.com',
  proxy: 'http://127.0.0.1:1080',
}

调试页面

{
  url: 'http://m.v.qq.com/tvp',
  debug: true,
}

草稿

{
  // 快速修改JSON数据
  url: '/api/json',
  target: function draft(data) {
    data.error = 1001;
  }
}

/**
json format
{
  "error": 0,
  "msg": "ok",
  "data": {
    "list": []
  }
}
*/

bproxy's People

Contributors

zobor avatar dependabot[bot] avatar

Watchers

 avatar

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.