Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

egg-http-proxy

1.0.1 • Public • Published

egg-http-proxy

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

Configure proxy middleware for egg. Use http-proxy-middleware.

Install

$ npm i egg-http-proxy --save

Usage

// {app_root}/config/plugin.js
exports.httpProxy = {
  enable: true,
  package: 'egg-http-proxy',
};

Configuration

Proxy /api requests to http://www.example.org:

// {app_root}/config/config.default.js
exports.httpProxy = {
  '/api': 'http://www.example.org'
};

A request to /api/users will now proxy the request to http://www.example.org/api/users.

If you don't want /api to be passed along, we need to rewrite the path:

// {app_root}/config/config.default.js
exports.httpProxy = {
  '/api': {
    target: 'http://www.example.org',
    pathRewrite: {'^/api' : ''}
  }
};

For more advanced usages, checkout http-proxy-middleware options documentation.

Questions & Suggestions

Please open an issue here.

License

MIT

Install

npm i egg-http-proxy

DownloadsWeekly Downloads

64

Version

1.0.1

License

MIT

Unpacked Size

6.62 kB

Total Files

7

Last publish

Collaborators

  • avatar