All Projects → eggjs → egg-development-proxyagent

eggjs / egg-development-proxyagent

Licence: MIT license
[DEPRECATED] A proxy adapter for debugging httpclient on egg.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to egg-development-proxyagent

egg-development
egg plugin for development
Stars: ✭ 56 (+180%)
Mutual labels:  egg-plugin, egg-development
Egg Validate
validate plugin for egg
Stars: ✭ 224 (+1020%)
Mutual labels:  egg-plugin
Egg Sofa Rpc
SOFARPC plugin for egg
Stars: ✭ 71 (+255%)
Mutual labels:  egg-plugin
Egg Multipart
multipart plugin for egg
Stars: ✭ 145 (+625%)
Mutual labels:  egg-plugin
Egg Passport
passport plugin for egg
Stars: ✭ 98 (+390%)
Mutual labels:  egg-plugin
Egg Oauth2 Server
🌟 OAuth2 server plugin for egg.js based on node-oauth2-server
Stars: ✭ 174 (+770%)
Mutual labels:  egg-plugin
Egg View React Ssr
Egg React Server Side Render (SSR) Plugin
Stars: ✭ 55 (+175%)
Mutual labels:  egg-plugin
egg-onerror
error handler for egg
Stars: ✭ 55 (+175%)
Mutual labels:  egg-plugin
Egg Socket.io
socket.io plugin for eggjs.
Stars: ✭ 209 (+945%)
Mutual labels:  egg-plugin
Egg Cors
CORS plugin for egg
Stars: ✭ 140 (+600%)
Mutual labels:  egg-plugin
Egg View Vue
vue view plugin for egg
Stars: ✭ 136 (+580%)
Mutual labels:  egg-plugin
Egg Router Plus
The missing router feature for eggjs
Stars: ✭ 117 (+485%)
Mutual labels:  egg-plugin
Cool Admin Api
cool-admin-api 是基于egg.js、typeorm、jwt等封装的api开发脚手架、快速开发api接口
Stars: ✭ 188 (+840%)
Mutual labels:  egg-plugin
Egg Schedule
Schedule plugin for egg
Stars: ✭ 76 (+280%)
Mutual labels:  egg-plugin
Egg Redis
redis plugin for egg
Stars: ✭ 234 (+1070%)
Mutual labels:  egg-plugin
Egg Mongo Native
MongoDB egg.js plugin using native driver.
Stars: ✭ 69 (+245%)
Mutual labels:  egg-plugin
Skyapm Nodejs
The NodeJS server side agent for Apache SkyWalking
Stars: ✭ 124 (+520%)
Mutual labels:  egg-plugin
Egg Mp
EggJS插件:微信公众平台基本服务
Stars: ✭ 153 (+665%)
Mutual labels:  egg-plugin
egg-cookies
cookies module for egg, base on pillarjs/cookies
Stars: ✭ 28 (+40%)
Mutual labels:  egg-plugin
egg-passport-local
wrap passport-local strategy for egg-passport
Stars: ✭ 44 (+120%)
Mutual labels:  egg-plugin

egg-development-proxyagent

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Nowadays lots of services are built upon HTTP protocol. So it's quite common to invoke backend services based on HTTP.

There is a built-in httpclient in Egg framework so that we can use it to invoke HTTP services easily.

This plugin provides a way of capturing HTTP request for debugging purpose.

DEPRECATED

This plugin is deprecated, instead, you just need to add below code to config.local.js

// config.local.js
module.exports = () => {
  const config = {};

  // add http_proxy to httpclient
  if (process.env.http_proxy) {
    config.httpclient = {
      request: {
        enableProxy: true,
        rejectUnauthorized: false,
        // proxy: process.env.http_proxy,
      },
    };
  }

  return config;
}

then start your application by:

$ http_proxy=http://127.0.0.1:8888 npm run dev

Install

npm i egg-development-proxyagent --save-dev
// config/plugin.local.js
exports.proxyagent = {
  enable: true,
  package: 'egg-development-proxyagent',
};

Usage

This plugin will take effect only in local env. Because it overrides the agent and httpsAgent of httpclient, so it will work for every request. And also you can delegate HTTPS requests via HTTP.

http_proxy or HTTP_PROXY environment variable will be used if set in Bash. Or you can specify it when you start app:

$ http_proxy=http://127.0.0.1:8888 node index.js

Capturing HTTPS Traffic

By default the http_proxy(or HTTP_PROXY) mentioned above will be passed to httpsAgent of urllib, and rejectUnauthorized = false will be set.

However, when using self-signed certificate we need to configure the certificate, shown as follows:

ca String | Buffer | Array - An array of strings or Buffers of trusted certificates. If this is omitted several well known "root" CAs will be used, like VeriSign. These are used to authorize connections. Notes: This is necessary only if the server uses the self-signed certificate

// config/config.default.js
exports.proxyagent = {
  ca: 'xxxxxxxxxxxx',
};

Capturing Tool

Note: Capturing tool is not in this plugin, you can use one of them below:

  • charles
  • fiddler
  • anyproxy is a capturing tool writtern in node. It provides a web console, it's a good replacement of charles.
$ npm install anyproxy -g
$ anyproxy --port 8888
$ open http://localhost:8002

Screenshot:

anyproxy

Questions & Suggestions

Please open an issue here.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].