egg-http-proxy
Configure proxy middleware for egg. Use http-proxy-middleware.
Install
$ npm i egg-http-proxy --save
Usage
exports.httpProxy = {
enable: true,
package: 'egg-http-proxy',
};
Configuration
Proxy /api
requests to http://www.example.org
:
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:
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